Got to replace prefs
with App-Prefs
, here is my Swift helper methods to support both iOS 10 and lower, tested on iOS 9 & 10
class Helper {
static func openLocationSettings() {
if #available(iOS 10.0, *) {
openSettings(url: "App-Prefs:root=Privacy&path=LOCATION")
} else {
openSettings(url: "prefs:root=LOCATION_SERVICES")
}
}
static func openSettings(url: String) {
guard let settingsUrl = URL(string: url), UIApplication.shared.canOpenURL(settingsUrl) else { return }
if #available(iOS 10.0, *) {
UIApplication.shared.open(settingsUrl)
} else {
UIApplication.shared.openURL(settingsUrl)
}
}
}
Example 1 Open Location Settings:
Helper.openLocationSettings()
Example 2 Open Application Settings:
Helper.openSettings(url: UIApplicationOpenSettingsURLString)