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"]];
The same exact code should work, but for iOS 10 you need to do some additional work by adding "prefs" to the URL Types:
After selecting your target:
It should be similar to this:
Now, your code should works fine.
UPDATE:
If it -somehow- did not work as expected, you might want to follow this workaround.
Hope that helped.
In iOS 10, a new url is required. Try using this code which tests both urls :
NSArray* urlStrings = @[@"prefs:root=WIFI", @"App-Prefs:root=WIFI"];
for(NSString* urlString in urlStrings){
NSURL* url = [NSURL URLWithString:urlString];
if([[UIApplication sharedApplication] canOpenURL:url]){
[[UIApplication sharedApplication] openURL:url];
break;
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With