how to programmatically open the WIFI settings in objective c in iOS9

As per Apple's New Review standards, we are not supposed to use this way to open Wi-Fi Settings. I have been using this for long time in my app and recently Apple rejected with the below comment.

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.

So you can just navigate to settings of the app by using UIApplicationOpenSettingsURLString.

Swift Code:

if let settingsUrl = URL.init(string: UIApplicationOpenSettingsURLString), UIApplication.shared.canOpenURL(settingsUrl) {
                    UIApplication.shared.openURL(settingsUrl)
                }

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

This is my code

if (&UIApplicationOpenSettingsURLString != NULL) { 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=WIFI"]]; 
} 

Try to add prefs to URL schemes like https://stackoverflow.com/a/31253743/3668465 did


All conditions:

    NSURL * urlCheck1 = [NSURL URLWithString:@"App-Prefs:root=WIFI"];
    NSURL * urlCheck2 = [NSURL URLWithString:@"prefs:root=WIFI"];
    NSURL * urlCheck3 = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

    if ([[UIApplication sharedApplication] canOpenURL:urlCheck1])
    {
        [[UIApplication sharedApplication] openURL:urlCheck1];
    }
    else if ([[UIApplication sharedApplication] canOpenURL:urlCheck2])
    {
        [[UIApplication sharedApplication] openURL:urlCheck2];
    }
    else if ([[UIApplication sharedApplication] canOpenURL:urlCheck3])
    {
        [[UIApplication sharedApplication] openURL:urlCheck3];
    }
    else
    {
        //Unable to open settings app.
    }