Case: For current location, the user selected "Dont allow" on app install, so is there a way that I can ask again for the user location and trigger the native iphone alert for current location??
I seen some posts on stackoverflow but there are old, is there a solution now to call in new sdk or someone found a way,
Post referred: CLLocation ask again for permission
iOS 13 will keep asking you about the apps using your location in the background unless you tap “Change to Only While Using.” iOS won't warn you about apps that can only access your location while you're using them. The good news is that we've noticed these prompts becoming less frequent over time.
If you can't find your current location on your iPhone, iPad, or iPod touch. Turn on Location Services and Location Access for Maps. In the Settings app, tap Privacy, then tap Location Services. Make sure Location Services is on, and make sure Maps is set to While Using the App or Widgets.
Unfortunately you can't do that. One thing you can do is to prompt the user to change the location settings.
if (![CLLocationManager locationServicesEnabled])
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Location Service Disabled"
message:@"To re-enable, please go to Settings and turn on Location Service for this app."
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
in ios8, apple has introduced a UIApplicationOpenSettingsURLString constant which is the location of the device's "settings" view.
you can code the following (in swift) to direct the user to the settings view:
switch CLLocationManager.authorizationStatus() {
case .AuthorizedWhenInUse, .Restricted, .Denied:
let alertController = UIAlertController(
title: "Background Location Access Disabled",
message: "In order to be notified, please open this app's settings and set location access to 'Always'.",
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)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With