When I try to use map in iOS 8, I get below error.
Trying to start MapKit location updates without prompting for location authorization. Must call -[CLLocationManager requestWhenInUseAuthorization] or -[CLLocationManager requestAlwaysAuthorization] first.
For this I tried solution from here, but still no luck.
Below is what I did.
Step 1. Have entry in Info.plist
NSLocationWhenInUseUsageDescription - This is test text
Step 2. Updated -(CLLocationCoordinate2D) getLocation
-(CLLocationCoordinate2D) getLocation{
CLLocationManager *locationManager = [[[CLLocationManager alloc] init] autorelease];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
// this is change
if(IS_OS_8_OR_LATER) {
[locationManager requestWhenInUseAuthorization];
}
[locationManager startUpdatingLocation];
CLLocation *location = [locationManager location];
CLLocationCoordinate2D coordinate = [location coordinate];
return coordinate;
}
Step 3. Prefix.pch
#define IS_OS_8_OR_LATER ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
Step 4. Delete the app again with below in viewDidLoad.
CLLocationCoordinate2D theCoordinate;
theCoordinate = [self getLocation];
NSLog(@"ffffff===%f===%f", theCoordinate.latitude, theCoordinate.longitude);
Still I get output as
ffffff===0.000===0.000
Note:
I get warning, but that is just for half seconds and disappears and then I get message as
CLLocationCoordinate2D theCoordinate;
theCoordinate = [self getLocation];
NSLog(@"ffffff===%f===%f", theCoordinate.latitude, theCoordinate.longitude);
When I go in setting to check the status for Location, below is what I have.
Any idea why this is happening?