Objective-C 2.0 code
- (void)gotoSettings {
NSString *urlString = @"App-Prefs:root=WIFI";
NSURL *url = [NSURL URLWithString:urlString];
if ([[UIApplication sharedApplication] canOpenURL:url]) {
if (@available(iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
} else {
[[UIApplication sharedApplication] openURL:url];
}
}
}
Swift Code
/// 前往Wi-Fi设置页面
func gotoSettings() {
let urlStr:String = "App-Prefs:root=WIFI"
let url = NSURL.init(string: urlStr)
if UIApplication.shared.canOpenURL(url! as URL) {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url! as URL, options: [:], completionHandler: nil)
} else {
UIApplication.shared.openURL(url! as URL)
}
}
}
Some jumps supported by iOS10:
- battery power
App-Prefs:root=BATTERY_USAGE
- Wireless LAN
App-Prefs:root=WIFI
- Bluetooth
App-Prefs:root=Bluetooth
- cellular network
App-- Prefs:root=MOBILE_DATA_SETTINGS_ID
- Personal Hotspot
App-Prefs:root=INTERNET_TETHERING
- operator
App-Prefs:root=Carrier
- notify
App-Prefs:root=NOTIFICATIONS_ID
- universal
App-Prefs:root=General
- General-About This Machine
App-Prefs:root=General&path=About
- General - Keyboard
App-Prefs:root=General&path=Keyboard
- General - Accessibility
App-Prefs:root=General&path=ACCESSIBILITY
- General - Language & Region
App-Prefs:root=General&path=INTERNATIONAL
- generic-revert
App-Prefs:root=Reset
- wallpaper
App-Prefs:root=Wallpaper
- Siri
App-Prefs:root=SIRI
- privacy
App-Prefs:root=Privacy
- Privacy - Photos
App-Prefs:root=Privacy&path=PHOTOS
- Privacy-Camera
App-Prefs:root=Privacy&path=CAMERA
Remarks : Jump to the corresponding page of privacy,path
= the corresponding page - Safari
App-Prefs:root=SAFARI
- music
App-Prefs:root=MUSIC
- music - equalizer
App-Prefs:root=MUSIC&path=com.apple.Music:EQ
- photo and camera
App-Prefs:root=Photos
- FaceTime
App-Prefs:root=FACETIME
The above method has been deprecated, and Apple will reject applications using this method
changed tolet urlStr = UIApplication.openSettingsURLString
reference
Solution for jumping from APP to system setting interface
Author: NapoleonY
Link: https://www.jianshu.com/p/8645a1b1bdaa
Source: Jianshu
The copyright belongs to the author. For commercial reprint, please contact the author for authorization, for non-commercial reprint, please indicate the source.