I have an IOS 8-only app in which I want to use location services to obtain the device's latitude and longitude. I think I have everything implemented correctly, but the app never asks the user if it's okay to use location services, the CLAuthorizationStatus never changes from kCLAuthorizationStatusNotDetermined and the CLLocationManager delegate method
- (void)locationManager:(CLLocationManager *)manager didUpdateHeading:(CLHeading *)newHeading
never gets called.
Here's the CLLocationManager defined in the interface file for the viewcontroller:
__strong CLLocationManager *locationManager;
Here's the code in the viewcontroller:
- (void)viewDidLoad{
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
if (status == kCLAuthorizationStatusNotDetermined) {
[locationManager requestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];
//... other viewDidLoad code
}
The Info.plist file for the app has an entry for NSLocationWhenInUseUsageDescription.
Debug tracing shows that the line
[locationManager requestWhenInUseAuthorization];
gets executed, but the dialog requesting the user to okay location services does not appear.
Location services in this app worked correctly under iOS 7 - I'm clearly doing something wrong, or not doing something I need to do to make it work in iOS 8. But I have dug around looking for insights, and it looks to me as if I'm doing everything correctly.
Any ideas and/or suggestions? Thanks in advance.