Since I updated to iOS SDK 8 and 8.1, there have been many problems, including that the method of CLLocationManager didUpdateLocations is no longer called.
Here the code: In viewDidLoad:
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters; // 100 m
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0) {
[locationManager requestAlwaysAuthorization];
}
[locationManager startUpdatingLocation];
The method:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{ NSLog(@"Call?"); }
A couple of thoughts:
Are you testing this on simulator or on device? You must test this on actual device. FWIW, didUpdateLocations
works fine on my iOS 8.1 device.
Make sure that you specified the NSLocationAlwaysUsageDescription
string or else the app won't present the authorization message, and you won't be authorized.
Obviously, if you don't need "always usage", you should just requestWhenInUseAuthorization
and then you must specify NSLocationWhenInUseUsageDescription
string.
Have you checked [CLLocationManager authorizationStatus]
? I do that before I even try to authorize or start location services, because if it's either kCLAuthorizationStatusDenied
or kCLAuthorizationStatusRestricted
, the location services won't work until the user goes to settings and remedies that. You may want to present them a message to that effect if you get either of these authorization codes.
Have you implemented locationManager:didFailWithError:
? Does it report anything?
Have you implemented locationManager:didChangeAuthorizationStatus:
? Are you getting this called with a successful authorization status?