iOS Launching Settings -> Restrictions URL Scheme

后端 未结 13 1265
自闭症患者
自闭症患者 2020-11-22 09:42

I\'ve recently discovered the awesome iOS5 custom Settings URL Scheme, which can be explained in detail at this great website.

I\'ve found this to work, dir

相关标签:
13条回答
  • 2020-11-22 10:16

    Works Fine for App Notification settings on IOS 10 (tested)

    if(&UIApplicationOpenSettingsURLString != nil){
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    }
    
    0 讨论(0)
  • 2020-11-22 10:19

    As of iOS8 you can open the built-in Settings app with:

    NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
       [[UIApplication sharedApplication] openURL:url];
    }
    

    The actual URL string is @"app-settings:". I tried appending different sections to the string ("Bluetooth", "GENERAL", etc.) but seems only linking to the main Settings screen works. Post a reply if you find out otherwise.

    0 讨论(0)
  • 2020-11-22 10:22

    As of iOS10 you can use

    UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root")!) 
    

    to open general settings.

    also you can add known urls(you can see them in the most upvoted answer) to it to open specific settings. For example the below one opens touchID and passcode.

    UIApplication.sharedApplication().openURL(NSURL(string:"App-Prefs:root=TOUCHID_PASSCODE")!)
    
    0 讨论(0)
  • 2020-11-22 10:22

    Here is something else I found:

    1. After I have the "prefs" URL Scheme defined, "prefs:root=Safari&path=ContentBlockers" is working on Simulator (iOS 9.1 English), but not working on Simulator (Simplified Chinese). It just jump to Safari, but not Content Blockers. If your app is international, be careful.
      Update: Don't know why, now I can't jump into ContentBlockers anymore, the same code, the same version, doesn't work now. :(

    2. On real devcies (mine is iPhone 6S & iPad mini 2), "Safari" should be "SAFARI", "Safari" not working on real device, "SAFARI" now working on simulator:

      #if arch(i386) || arch(x86_64)
          // Simulator
          let url = NSURL(string: "prefs:root=Safari")!
      #else
          // Device
          let url = NSURL(string: "prefs:root=SAFARI")!
      #endif
      
      if UIApplication.sharedApplication().canOpenURL(url) {
          UIApplication.sharedApplication().openURL(url)
      }
      
    3. So far, did not find any differences between iPhone and iPad.

    0 讨论(0)
  • 2020-11-22 10:24

    Solution for iOS10. Works fine.

    NSURL *URL = [NSURL URLWithString:@"App-prefs:root=TWITTER"];
    [[UIApplication sharedApplication] openURL:URL options:@{} completionHandler:nil];
    
    0 讨论(0)
  • 2020-11-22 10:25

    I wanted to open the Bluetooth Menu in the Settings Application and the above path (prefs:root=General&path=Bluetooth) didn't work for me. What ended up working for me was

    UIApplication.sharedApplication().openURL(NSURL(string:"prefs:root=Bluetooth")!)
    

    Make sure you have the prefs URL Scheme defined first.

    0 讨论(0)
提交回复
热议问题