How to programmatically open the WIFI settings in Objective-C on iOS 10
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"]];
}
}
URL scheme prefs:root=PASS iOS10
Since iOS 10, it's not possible to open the Settings
app from a third party app. The only settings that are allowed to be opened are Keyboard setting but only by a custom keyboard extension and your own application settings.
More details: here
Note: Even for iOS 9, using the URL string that is mentioned in the question can lead to app rejection as it violates iOS App Review Guidelines.
window.location.href = prefs:root=Settings not work in iOS 10
Just replace "prefs" to "App-Prefs" for iOS 10
prefs:root=CASTLE not working to open iCloud Settings in IOS10?
For iOS 10 onwards change prefs:root=CASTLE
to App-Prefs:root=CASTLE
and this will work fine
let settingsCloudKitUrl = URL(string:"App-Prefs:root=CASTLE")
if let url = settingsCloudKitUrl {
if #available(iOS 10, *) {
if UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url, options: [:], completionHandler: nil)
}
} else {
UIApplication.shared.openURL(url)
}
}
Related Topics
Pulling Data from a Cmsamplebuffer in Order to Create a Deep Copy
Delete Cell from Uicollectionview Without Reloading from Top
How to Resize Uitableviewcell to Fit Its Content
Uinavigationcontroller Interactivepopgesturerecognizer Working Abnormal in iOS7
Multiple Checkmark When Row Selected in Uitableview iOS
How to Tell If Blocks in Loop All Have Completed Executing
iOS 11+ How to Migrate Existing Core Data to Shared App Group for Use in Extension
How to Play Movie with a Url Using a Custom Nsurlprotocol
Installed App from Testflight Crashes Due to Alleged Uisearchdisplaycontroller
Import Framework in Swift Project, Xcode
Accessing the Settings App from Your App in iOS 8
How to Detect a Dual Core CPU on iOS
#Import <Libxml/Tree.H> File Not Found After Xcode Update
Presenting Uialertcontroller from Uitableviewcell
Get Current iOS Device Orientation Even If Device's Orientation Locked