iOS jumps to the Wi-Fi settings page

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 powerApp-Prefs:root=BATTERY_USAGE
  • Wireless LANApp-Prefs:root=WIFI
  • BluetoothApp-Prefs:root=Bluetooth
  • cellular networkApp-- Prefs:root=MOBILE_DATA_SETTINGS_ID
  • Personal HotspotApp-Prefs:root=INTERNET_TETHERING
  • operatorApp-Prefs:root=Carrier
  • notifyApp-Prefs:root=NOTIFICATIONS_ID
  • universalApp-Prefs:root=General
  • General-About This MachineApp-Prefs:root=General&path=About
  • General - KeyboardApp-Prefs:root=General&path=Keyboard
  • General - AccessibilityApp-Prefs:root=General&path=ACCESSIBILITY
  • General - Language & RegionApp-Prefs:root=General&path=INTERNATIONAL
  • generic-revertApp-Prefs:root=Reset
  • wallpaperApp-Prefs:root=Wallpaper
  • Siri App-Prefs:root=SIRI
  • privacyApp-Prefs:root=Privacy
  • Privacy - PhotosApp-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
  • musicApp-Prefs:root=MUSIC
  • music - equalizerApp-Prefs:root=MUSIC&path=com.apple.Music:EQ
  • photo and cameraApp-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.

Guess you like

Origin blog.csdn.net/super_man_ww/article/details/116484201