Search code examples
iosobjective-cxcodecllocationmanagercllocationcoordinate2d

CCLocation with startMonitoringForRegion is not working anymore since iOS 10


I use this code becore iOS 10 and it worked well.

    //Start monitoring
    CLLocationCoordinate2D centre;
    centre.latitude = [latZone floatValue];
    centre.longitude = [lonZone floatValue];

    [self.locationManager startMonitoringForRegion:[[CLCircularRegion alloc] initWithCenter:centre radius:[radiusZone floatValue] identifier:nameZone]];

But since the iOS 10 version, it doesn't work anymore. It doesn't call didEnterRegion: didExitRegion: & didStartMonitoringForRegion:

Any ideas?


Solution

  • I finally solved it by adding two keys in the info.plist :

    NSLocationAlwaysUsageDescription
    NSLocationWhenInUseUsageDescription
    

    And adding that two lines just before :

        [self.locationManager requestAlwaysAuthorization];
        [self.locationManager requestWhenInUseAuthorization];