How to open Location Services from iOS application for iOS 11 beta?

This is my snippet code:


if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) { NSURL *URL = [NSURL URLWithString:@"App-prefs:root=Privacy&path=LOCATION"]; [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil]; }


This code works fine for iOS 10.0 to 10.3.3 but when I run this code for iOS 11(beta), the application goes into the background but the Setting page doesn't get opened.

Replies

Can you log the current system version and then test in the if ?


// log systemVersion

if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 10.0) {
     NSURL *URL = [NSURL URLWithString:@"App-prefs:root=Privacy&path=LOCATION"];
     // log that you passed here
     [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
}

There seem to be an extra open parenthesis at the beginning

if (([[[

Can you check for it ?

Hi,

This url worked before IOS 11 and swift 3. -> App-Prefs:root =Privacy&path=LOCATION

But on iOS 11 devices, only the settings screaen is opened. Can you find a solution? Swift 4 and ios 11.2

Any Solutions From that issue?

For me what worked was App-Prefs:Privacy&path=LOCATION root= is no longer needed apparently (iOS 16.4.1, year 2023)

Please don’t build products that rely on undocumented URL schemes. These are not considered API and can break without notice. See this post.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"