how to programmatically open Settings > Privacy > Location Services in iOS 11+?

前端 未结 2 898
温柔的废话
温柔的废话 2021-01-06 08:59

If locationServicesEnabled return false, I\'m prompting the user to enable their Location Services. The following URL works for 10.0+, redirecting the user to the Settings a

相关标签:
2条回答
  • 2021-01-06 09:22

    Apple published a list of URLs which they explicitly allow at this link. Unfortunately if you use other URLs (such as the one you are trying to use) this can get your app rejected from the App Store.

    Short answer: You cannot do what you are trying to do without breaking the App Store rules.

    0 讨论(0)
  • 2021-01-06 09:27

    Use this-

    UIApplication.shared.open(URL(string:UIApplicationOpenSettingsURLString)!)
    

    Using App-prefs may lead to the rejection of the app on app store.

    Or you can try this also-

    if let bundleId = Bundle.main.bundleIdentifier,
    let url = URL(string: "\(UIApplication.openSettingsURLString)&path=LOCATION/\(bundleId)") {
        UIApplication.shared.open(url, options: [:], completionHandler: nil)
    }
    
    0 讨论(0)
提交回复
热议问题