I Want to emit this alert:
Turn On Location Services to allow maps to determine your location
I need both "Settings" and "Cancel" exactly like the "maps" application.
"Settings" should open settings->general->location services
I didn't find the way to open the settings page.
Can you help me?
Thanks
Creating the alert is pretty straightforward, it's just a (faux-)modal UIView.
However, it's not possible to open the Settings app programmatically, at least not without using private methods that will prevent your app from being approved for the App Store.
This is not possible to accomplish on your own. However, if your application needs to access location services the OS will present a dialog like this for you as seen below.
Edit: Brant mentioned below that "the message can be customized by setting the value of the purpose property on your CLLocationManager."
You can't open specific settings page like General, Locatios etc., but you can open settings page in iOS 8.
- (void)openSettings
{
BOOL canOpenSettings = (&UIApplicationOpenSettingsURLString != NULL);
if (canOpenSettings)
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
[[UIApplication sharedApplication] openURL:url];
}
}
Swift 2.0 version:
func showLocationSettingAlert() {
let alertController = UIAlertController(
title: "Location Access Disabled",
message: "Location settings",
preferredStyle: .Alert)
let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
alertController.addAction(cancelAction)
let openAction = UIAlertAction(title: "Open 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)
}
It's not possible to open the setting pane programmatically at this moment. Refer to here.
It's not something you add. That screen comes up when the applications wants to use locational services but it's turned off in the settings.
The same thing happens with push notifications.
How other said, you can't open Settings app programmatically if you want your app on the App Store.
This popup is automatically "generated" at launch of your app if it support and uses a determined functions like Location Service.
You can find more informations about this service on the Reference Library: https://developer.apple.com/library/ios/navigation/#section=Frameworks&topic=CoreLocation