UPDATE: THIS IS NOT A DUPLICATE. I have already added the required key to the info.plist as stated in my original question and the issue remains. I have tried all three keys in various combinations.
Before anyone gets upset, I have read through many Apple Dev forum posts and stack overflow posts and cannot figure out why my app refuses to prompt the user to allow When In Use authorization.
I've added the following key to my Info.plist
file with an accompanying String value:
NSLocationWhenInUseUsageDescription
I've then written (both in Swift and Obj-C) the code that should prompt 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 basically copied straight from the Apple "LocateMe" sample code.
No matter what various sequences or minor changes I try, the app never prompts to allow authorization. I've used a switch statement to determine the state of [CLLocationManager authorizationStatus]
, but continually recieve a "Not Determined" 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'm running Xcode 6.2 (6C101) with iOS 8.1.2 physical device and iOS 8.2 (12D5452a) simulator for testing.