When the user’s location services are turned off, I want to invite them to turn on using the UIAlertController. One of the parameters in Alert Controller must take them directly in the location services (for the OS, not for the application). Right now, I got to the point that I was able to send the user permissions for my specific application, but not for general OS location settings. Is there a way to send the user directly to OS location settings from UIAlertController?
Here is the current code (located in viewDidAppear):
if (CLLocationManager.locationServicesEnabled())
{
daMap.delegate = self
daMap.mapType = MKMapType.Satellite
daMap.showsUserLocation = true
} else {
let alertController = UIAlertController(
title: "We Can't Get Your Location",
message: "Turn on location services on your device.",
preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
alertController.addAction(cancelAction)
let openAction = UIAlertAction(title: "Location Settings", style: .Default) { (action) in
if let url = NSURL(string:UIApplicationOpenSettingsURLString) {
UIApplication.sharedApplication().openURL(url)
}
}
alertController.addAction(openAction)
self.presentViewController(alertController, animated: true, completion: nil)
}