0

I keep seeing that you can use

if UIApplication.shared.canOpenURL(settingsUrl) {
    UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
        print("Settings opened: \(success)")
    })
}

but it only works for iOS 10 and above. But how can I do the same thing for iOS 8?

rminaj
  • 560
  • 6
  • 28

3 Answers3

0

UIApplication.openSettingsURLString will return settings url string.

if let settingsURL = URL(string: UIApplication.openSettingsURLString),
    UIApplication.shared.canOpenURL(settingsURL) {
    UIApplication.shared.open(settingsURL, completionHandler: { (success) in
        print("Settings opened: \(success)")
    })
}
Satish
  • 2,015
  • 1
  • 14
  • 22
0

At the moment, I rarely see any application support for iOS 8 anymore. But if you want to know, here is the answer:

let urlStr = "yourURL"
if let linkURL = URL(string: urlString), UIApplication.shared.openURL(URL) {
 UIApplication.shared.openURL(linkURL)
}
Hang Ngo
  • 1
  • 1
0

This is what worked for me

if UIApplication.openSettingsURLString != nil{
    if let aString = URL(string: UIApplication.openSettingsURLString){
        UIApplication.shared.openURL(aString)
    }
}
rminaj
  • 560
  • 6
  • 28