I need to ask user to enable Location Services if disabled. I have created an Alert which asks user if he wants to enable Location. I user clicks Ok I want to open Location Services page on iPhone as seen below:
I am trying ‘openSettingsURLString’ but it opens App settings instead of Location Services page, this is the code:
let url = URL(string: UIApplication.openSettingsURLString)
let settingsAction = UIAlertAction(title: NSLocalizedString("OK", comment: ""), style: .default) {
(UIAlertAction) in UIApplication.shared.open(url!, options: [:], completionHandler: nil)
self.dismiss(animated: true, completion: nil)
}
alertController.addAction(cancelAction)
alertController.addAction(settingsAction)
self.present(alertController, animated: true, completion: nil)
2
Answers
I believe this is not possible, you can only navigate to the settings of the app itself; Apple expects the user themself to navigate to location services. . I would recommend giving the user instructions on how to navigate to location services as an alternative such as some screenshots and the path they should take.
Open Settings App – This one should be OK to use.
Open Location Services
If this app is for personal use only and you do not plan to submit it to the App Store, then you should be ok to use the following. Otherwise, if you do plan to release your app, Apple will reject it upon review.