didUpdateLocations not called
Furthermore in iOS8 you must have two extra things:
Add a key to your
Info.plist
and request authorization from the location manager asking it to start.NSLocationWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
You need to request authorization for the corresponding location method.
[self.locationManager requestWhenInUseAuthorization]
[self.locationManager requestAlwaysAuthorization]
Code example:
self.locationManager = [[CLLocationManager alloc] init];self.locationManager.delegate = self;// Check for iOS 8. Without this guard the code will crash with "unknown selector" on iOS 7.if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { [self.locationManager requestWhenInUseAuthorization];}[self.locationManager startUpdatingLocation];
Source: http://nevan.net/2014/09/core-location-manager-changes-in-ios-8/
When I had this problem, it was due to a threading issue.
Make sure, that all of these methods are called on the main thread.It is very important, that not only the startUpdatingLocation
method is called on the main thread, but the others as well.
You can force code to be run on the main thread by wrapping it inside
dispatch_sync(dispatch_get_main_queue(), ^{});
Also check out this answer.
Make sure you added CLLocationManager as a property.
@property (nonatomic , strong) CLLocationManager *locationManager;