How to programmatically open the WIFI settings in Objective-C on iOS 10

ios, ios10, iphone, objective-c, wifi

Solution

This works fine on iOS 10,

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

In the `URL Schemes` write

prefs

See the image,

Then add the following code,

-(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"]];
    }
}

Problem

The following code works fine on iOS 9, see this post. But it doesn't work on iOS 10. How to open WIFI settings programmatically on iOS 10 ``` [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]]; ```

Original source

Related problems