5
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), application goes into background but Setting page doesn't get opened.

Shrikant Phadke
  • 358
  • 2
  • 11

3 Answers3

2

application goes into background but Setting page doesn't get opened.

It was crash of Settings.app. From iOS 11 Beta 7, the crash has been fixed. But it still cannot open the specific path with scheme like @"App-Prefs:root=Privacy&path=LOCATION".

I was trying to dig into the de-compiled code of Settings.app(Which is actually Preferences.app). Seems like it still uses the schemes above we tried to use, since I found the scheme strings in same form in de-compiled codes.

And it might be added sort of permission control in SpringBoard to manager that which process can open specific path in Settings properly.

Anyway, for now in iOS 11 I can only use

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];

to open settings.

  • @ShrikantPhadke It might not. According to Launcher apps developer's [blog](https://cromulentlabs.wordpress.com/2017/08/22/on-upcoming-changes-in-ios-11/), Apple intentionally disabled this 'private' feature for third party developers. – phoenixxyang Sep 08 '17 at 12:11
0

You should check if iOS can open the URL you're trying to call. You can do this with if([UIApplication sharedApplication] canOpenURL:URL]]){...}. If iOS 11 can't do that, you should add an else statement to check for iOS 11 and engineer a new solution.

jbehrens94
  • 2,356
  • 6
  • 31
  • 59
  • That means that your URL will not work in iOS 11, so you will have to find another way. In another SO question, I found you can open the Settings app with `[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];`. [link](https://stackoverflow.com/questions/5655674/opening-the-settings-app-from-another-app) – jbehrens94 Aug 07 '17 at 14:03
  • 1
    NSURL *URL = [NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]; if ([[UIApplication sharedApplication] canOpenURL:URL]) { NSLog(@"can open"); } else{ NSLog(@"can not open"); } returning "can open". Still app doesn't navigate to setting. – Shrikant Phadke Aug 18 '17 at 10:10
  • You don't read what I'm saying: you need to replace `[NSURL URLWithString:@"App-Prefs:root=Privacy&path=LOCATION"]` with another solution, because obviously it doesn't work anymore. What the right NSURL is, I don't know, you will have to reverse engineer that. – jbehrens94 Aug 18 '17 at 12:48
0

All clues point to an iOS bug or change that the developers have not been notified about. It's beta 10 and this still doesn't work. Best guess, submit a bug report to apple.

trusk
  • 1,634
  • 2
  • 18
  • 32