Previously i was using XCode 8 beta 3 and testing it on iOS 10 device. But now i want my app to support previous versions of iOS. When i am trying to run it on iOS 9 device after decreasing the deployment target from project settings, this particular method is showing error since it's only available for iOS 10.0 or newer:
UIApplication.shared().open((url as URL), options: [:], completionHandler: nil)
Use below code as it available in lower versions of iOS
if UIApplication.sharedApplication().canOpenURL(url!) {
UIApplication.sharedApplication().openURL(url!)
}
Swift 3.0 and above
// for versions iOS 10 and above
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:])
}
// for versions below iOS 10
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.openURL(url)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With