Re-enable location services for iPhone app

I struggled with requesting the location service of my iPhone app. If the user says "Do not allow", I am stuck in my "this application needs location services to work" ...

All attempts to re-apply for location services have proven futile, as several stacks attest.

Then I read that the only way to re-enable location services was to redirect the user to the location service settings using this:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"]]; 

But even this does not work (iPhone 4 and 4S, as on 5.1)

Is there no other way besides telling the user to go to the settings and then navigate it? It seems like it is so cool awkward.

+5
source share
1 answer

If the user has disabled the location service, there is no other way to tell the user to enable them again.

You can try redirecting, but this is only possible on iOS 5.0. So you can do it like:

NSURL *prefsURL = [NSURL URLWithString:@"prefs:root=LOCATION_SERVICES"];

if ([[UIApplication sharedApplication] canOpenURL:prefsURL]) {
   [[UIApplication sharedApplication] openURL:prefsURL];
} else {
  // Can't redirect user to settings, display alert view
  UIAlertView *alertView = ....

}
+2
source

All Articles