I have been struggling with the location service request for my iPhone app. If the user says "Don't allow", I'm stuck in my "this app needs location services in order to work"...
All attempts to re-apply for location services have been fruitless, which several stacks here can testify to.
Then I read that the only way to re-enable the 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 that doesn't seem to work (iPhone 4 and 4S, both on 5.1)
Is there really no other way, except telling the user to go to preferences and then guiding him through ? It seems so toe-twistingly bulky to me.
If the user turned the location service off, there is no other way then to tell the user to turn them on again.
You could try to redirect, 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 = ....
}
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