Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open Wifi Settings by "prefs:root=WIFI" failed in iOS 10

Tags:

ios

ios10

wifi

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?

like image 817
tbago Avatar asked Sep 30 '16 01:09

tbago


3 Answers

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."

like image 103
Luke Avatar answered Nov 17 '22 13:11

Luke


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!)
}
like image 25
Siddharth jain Avatar answered Nov 17 '22 14:11

Siddharth jain


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]];
}
like image 6
ronan Avatar answered Nov 17 '22 13:11

ronan