URL Scheme “Open Settings” ios

后端 未结 5 1910
后悔当初
后悔当初 2020-12-05 03:05

I know this question has been asked so many times. The answers say that this is not available in Xcode > 5.x. but I saw some apps that can use this(Go to Settings)(iOS7). Is

相关标签:
5条回答
  • 2020-12-05 03:16

    As of iOS 8, it's possible to launch the Settings app that directly opens your Privacy app section in this way:

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
    

    In Swift:

    if let settingsURL = NSURL(string: UIApplicationOpenSettingsURLString) {
        UIApplication.sharedApplication().openURL(settingsURL)
    }
    

    In Swift 3.0:

    if let settingsURL = URL(string: UIApplicationOpenSettingsURLString + Bundle.main.bundleIdentifier!) {
        UIApplication.shared.openURL(settingsURL as URL)
    }
    
    0 讨论(0)
  • 2020-12-05 03:16

    iOS 13, Swift 5.0

    Syntax for open settings changed [again] a tiny bit.

    if let url = URL(string:UIApplication.openSettingsURLString) {
         if UIApplication.shared.canOpenURL(url) {
           UIApplication.shared.open(url, options: [:], completionHandler: nil)
         }
      }
    
    0 讨论(0)
  • 2020-12-05 03:18

    Alerts on your screenshots are system alerts. The first occurs when app wants to use internet and have a blocked cellular data for application (and Wifi is not connected). The second occurs when an application wants to use location services, and you have turned off wifi. It is not possible control the display of these alerts.

    In iOS 8 (Xcode 6) is the ability to open the settings directly from the application. Please read this topics: How to open Settings programmatically like in Facebook app?

    Opening the Settings app from another app

    0 讨论(0)
  • 2020-12-05 03:22

    1.- Add URL Types

    2.- Use:

    Objective - C

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General"]];
    

    Swift

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

    3.- Other path find in this answer: iOS Launching Settings -> Restrictions URL Scheme

    0 讨论(0)
  • 2020-12-05 03:33

    This is not possible anymore in iOS 11, we can just open Settings. Here a Swift 4 code snippet:

    if let url = URL(string:UIApplicationOpenSettingsURLString) {
       if UIApplication.shared.canOpenURL(url) {
         UIApplication.shared.open(url, options: [:], completionHandler: nil)
       }
    }
    
    0 讨论(0)
提交回复
热议问题