I had do a test first,then post my answer:
The document said:openURL:
is deprecated in iOS10.Use openURL:options:completionHandler:
instead.
I had do a test first,then post my answer:
The document said:openURL:
is deprecated in iOS10.Use openURL:options:completionHandler:
instead.
Before iOS 10,you can use:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]];
After iOS 10,you'd better use:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]
options:[NSDictionary dictionary]
completionHandler:nil];
Open Location Service Setting in Swift 3:
if let url = URL(string: "App-Prefs:root=Privacy&path=LOCATION") {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url)
}
}
In Swift 3.0
let url = URL(string: "http://google.com")!
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
else{
NSLog("Cant open url")
}