How can I prompt the user to turn on location services after user has denied their use

后端 未结 11 2220
死守一世寂寞
死守一世寂寞 2020-11-29 20:06

I have an application with an explicit user interaction that makes use of the user\'s current location. If the user denies access to location services, I would still like su

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 20:31

    Here is the swift 3 implementation of the code provided by Markus and bjc.

    let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .alert)
    
    let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)
    let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .default) { (UIAlertAction) in
                    UIApplication.shared.openURL(NSURL(string: UIApplicationOpenSettingsURLString)! as URL)
                }
    
    alertController.addAction(cancelAction)
    alertController.addAction(settingsAction)
                self.present(alertController, animated: true, completion: nil)
    

提交回复
热议问题