UPDATE: THIS IS NOT A DUPLICATE. I have already added the necessary key to info.plist, as indicated in my original question, and the problem remains. I tried all three keys in different combinations.
Before anyone gets upset, I read a lot of posts about Apple Dev forums and stack overflows and cannot understand why my application refuses to offer the user permission to use In In Use.
I added the following key to my Info.plist file with the accompanying String value:
NSLocationWhenInUseUsageDescription
Then I wrote (in both Swift and Obj-C) code that should call the user:
@property CLLocationManager *location; ... @synthesize location; ... location = [[CLLocationManager alloc] init]; location.delegate = self; location.desiredAccuracy = kCLLocationAccuracyBest; location.distanceFilter = kCLDistanceFilterNone; [location requestWhenInUseAuthorization]; [location startUpdatingLocation]; I'm using the following CLLocationManagerDelegate methods. - (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations - (void) locationManager:(CLLocationManager *)manager didChangeAuthorizationStatus:(CLAuthorizationStatus)status
This was mostly copied directly from the Apple LocateMe sample code.
No matter what different sequences or minor changes I try, the application never asks for permission. I used the switch statement to determine the status of [CLLocationManager authorizationStatus] , but I constantly get the " [CLLocationManager authorizationStatus] " response.
if ([CLLocationManager locationServicesEnabled]) { switch ([CLLocationManager authorizationStatus]) { case kCLAuthorizationStatusAuthorizedAlways: NSLog(@"Always Authorized"); break; case kCLAuthorizationStatusDenied: NSLog(@"Denied"); break; case kCLAuthorizationStatusAuthorizedWhenInUse: NSLog(@"Authorized in Use"); break; case kCLAuthorizationStatusNotDetermined: NSLog(@"Not Determined"); break; case kCLAuthorizationStatusRestricted: NSLog(@"Restricted"); break; } }
Any help would be greatly appreciated. I am running Xcode 6.2 (6C101) with the physical device iOS 8.1.2 and iOS 8.2 (12D5452a) for testing.
ios objective-c cllocationmanager cllocation
Andrew
source share