0
I started developing for IOS and I can’t download inside a Webview using Xcode in the Swift language.
The Code is very simple, it opens a website, where it contains a button to download an Image file.
But after clicking the button, it opens the image on a white page.
If I press the image, it appears the save option, but when I click the Emulator closes and an Error message appears (Thread 9: signal SIGABRT
).
I’ve turned the Internet upside down and looked at other answers right here on Stack Overflow, but nothing worked for me.
import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {
var webView: WKWebView!
override func loadView() {
let webConfiguration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: webConfiguration)
webView.uiDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
let myURL = URL(string:"https://erroemdownloadios.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
}
}
Why is it urgent?
– Woss
Hello, Anderson. I am a Web developer, and a client of mine gave me an ultimatum, to develop the application on IOS, otherwise, cancel the system.
– Davi
When he hired you he said he needed to do it for iOS?
– hugocsl
No, but eventually this need arose and I need to develop this application, because I have another client who is also considering this hypothesis. I already developed three apps for Android, but I came across this obstacle, entering an environment that I’m not used to. You could help me Hugo ?
– Davi
@David You must be receiving SIGABIRT from the emulator because your app needs
NSPhotoLibraryAddUsageDescription
in your Info.plist. When the save action on mobile is activated from within your app, OS asks the user for permission to save the image through their app. Try putting this key and see if the crash goes away.– Igor Castañeda Ferreira
Hello Igor, thanks for the reply. I added in Info.plist a Key with name: Nsphotolibraryaddusagedescription with String type. Unfortunately the error continues :(
– Davi
Try "Privacy - Photo Library Additions Usage Description" and "Privacy - Photo Library Usage Description"
– George Gomes
Thanks for the reply George, He stopped closing the Emulator, but I went to check the folders and he did not save the image. You could help me with that ?
– Davi
Yes, but you have to check which method you are using to save this image, maybe it is better to create another question with more detail.
– George Gomes