Created
September 12, 2011 22:35
-
-
Save danlipert/1212671 to your computer and use it in GitHub Desktop.
iOS location services denial handling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* found on stack overflow: http://stackoverflow.com/questions/3401757/locationservicesenabled-test-passes-when-they-are-disabled-in-viewdidload | |
also: http://stackoverflow.com/questions/2333344/how-to-handle-dont-allow-for-location-manager | |
*/ | |
- (void)locationManager: (CLLocationManager *)manager | |
didFailWithError: (NSError *)error { | |
NSString *errorString; | |
[manager stopUpdatingLocation]; | |
NSLog(@"Error: %@",[error localizedDescription]); | |
switch([error code]) { | |
case kCLErrorDenied: | |
//Access denied by user | |
errorString = @"Access to Location Services denied by user"; | |
//Do something... | |
break; | |
case kCLErrorLocationUnknown: | |
//Probably temporary... | |
errorString = @"Location data unavailable"; | |
//Do something else... | |
break; | |
default: | |
errorString = @"An unknown error has occurred"; | |
break; | |
} | |
} | |
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error" message:errorString delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil]; | |
[alert show]; | |
[alert release]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment