19

I was using prefs:root=WIFI url scheme in my app with prefs entered in info.plist to open directly the iOS settings application in Wi-Fi settings and it was working great on iOS 9 but it does not work anymore on iOS 10.

Does anyone know if this is just a regression in the first developer preview or the way to open Wi-Fi settings has changed in iOS 10 or it is not allowed anymore?

tbago
  • 660
  • 1
  • 6
  • 19

7 Answers7

24

Just so it's explicit: Apple does not allow this. It's possible your app will make it through anyway, but this is the same as using any other undocumented API.

Here is the full list of supported Apple URL schemes.

Here's a thread where Apple confirms that "any Apple URL schemes that are not officially documented should be considered private API."

Luke
  • 7,110
  • 6
  • 45
  • 74
13

SWIFT 3.0:- working in iOS 10

@IBAction func openWifiSetting(_ sender: AnyObject) {
    let url = URL(string: "App-Prefs:root=WIFI") //for WIFI setting app
    UIApplication.shared.openURL(url!)
}
Siddharth jain
  • 439
  • 5
  • 9
  • 2
    Whoa! I had given up hope that this was possible post iOS 10.x. Have you found any reason to believe doing this will get an app rejected by the App Store? – Mark Peters Jan 31 '17 at 18:46
  • iOS11 is also OK – Alex Chan Jun 21 '17 at 09:36
  • 2
    This is forbidden by the app store guidelines, I just had an app rejected by the review team for doing this. "Your app uses the "prefs:root=" non-public URL scheme, which is a private entity. The use of non-public APIs is not permitted on the App Store because it can lead to a poor user experience should these APIs change." – Bersaelor Aug 23 '18 at 20:45
  • Mine was rejected too, after a couple of updates. Whoever find this answer helpful - you should realize all the risks. They don't just reject, but also add a note: "Continuing to use or conceal non-public APIs in future submissions of this app may result in the termination of your Apple Developer account" – Vitalii Sep 13 '18 at 16:40
6

My app is also using that api. Unfortunately apple disable this on iOS 10. Here's my solution: below iOS 10, it can still open Setting App. on iOS 10, it will go to a subpage(Cellular Data access) of Setting App, you can back to setting page by one click. I decide to keep it. because it's still convenient than user manually open Setting App.

NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
    [[UIApplication sharedApplication] openURL:url];
} else {
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
}
ronan
  • 1,611
  • 13
  • 20
6

try this for objective c in iOS 10

NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
   [[UIApplication sharedApplication] openURL:url];
} else {
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=WIFI"]];
}
Mohammad Rana
  • 133
  • 2
  • 2
2

Using "App-Prefs:root" instead of "prefs:root"

  • 1
    "To resolve this issue, please revise your app to provide the associated functionality using public APIs or remove the functionality using the "prefs:root" or "App-Prefs:root" URL scheme." I got this when my app was rejected. – Tejas K Jul 24 '18 at 09:02
  • 1
    Me too ! I got the same rejection ! (for > iOS11 your answer is wrong!) – iKK Aug 29 '18 at 21:01
2

iOS 10, to open your apps settings:

if let settingsURL = URL(string: UIApplicationOpenSettingsURLString) {  
                UIApplication.shared.openURL(settingsURL)
          }
userXYZ
  • 31
  • 1
1

This works fine on iOS 10,

Go to Targets --> (Application) --> Info --> URL Types --> +

In the URL Schemes write

prefs

Then Call,

- (void)openWifiSettings
{
    if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"prefs:root=WIFI"]]) {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
    } else {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"App-Prefs:root=WIFI"]];
    }
}
Shuvo Joseph
  • 894
  • 1
  • 12
  • 21