How can I check if the user has allowed location for mu app?
Normally I would use authorizationStatus
method of the CLLocationManager
class, but it
Hmm.. I didn't think to use authorizationStatus
or locationServicesEnabled
. What I did was the following:
MKUserLocation *userLocation = mapView.userLocation;
if (!userLocation.location) {
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];
[alert release];
return;
}
I'm glad to see there's a better method to check, but I haven't had any problems with the way I detect if my app is allowed to use the GPS.
Hope this helps!