2

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?"); }
Joker
  • 167
  • 1
  • 3
  • 12

4 Answers4

2

A couple of thoughts:

  1. 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.

  2. 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.

  3. 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.

  4. Have you implemented locationManager:didFailWithError:? Does it report anything?

  5. Have you implemented locationManager:didChangeAuthorizationStatus:? Are you getting this called with a successful authorization status?

Community
  • 1
  • 1
Rob
  • 415,655
  • 72
  • 787
  • 1,044
2

Need include MapKit.framework from Capabilities:

enter image description here

János
  • 32,867
  • 38
  • 193
  • 353
1

I had the same problem, and my code (viewdidupdate method) was missing this:

_mapView.delegate = self;

For some reason the app worked in ios 7 without the line, but in ios 8.1 didUpdateUserLocation was never called.

McFish
  • 39
  • 1
  • I'm not sure why this is downvoted. Forgetting to set the delegate is a very common problem. – JRam13 Jun 26 '15 at 14:09
  • That did it for me! The mapVIEW receives the events, so you should implement its delegate, makes sense – Radu Dec 14 '18 at 12:48
1

Specify both NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription in your plist:

enter image description here

Also in code, request authorization:

if ([self.locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { // or requestAlwaysAuthorization
    [self.locationManager requestWhenInUseAuthorization]; // or requestAlwaysAuthorization
}
[self.locationManager startUpdatingLocation];
MobileMon
  • 8,341
  • 5
  • 56
  • 75