1

I am using CLRegion for geofencing. I monitored CLCircularRegion set for notifyOnExit and notifyOnEntry. Here is my code:

 CLLocationCoordinate2D coordinateGYM = CLLocationCoordinate2DMake(lat,lng);
    CLCircularRegion *regionSet = [[CLCircularRegion alloc]initWithCenter:coordinateGYM radius:RADIUS identifier:strTitle];
    if(isExit)
    {
        regionSet.notifyOnExit = YES;
        regionSet.notifyOnEntry = NO;
    }
    else
    {
        regionSet.notifyOnExit = NO;
        regionSet.notifyOnEntry = YES;
    }
    [self.locationManager startMonitoringForRegion:regionSet];
    [self.locationManager startUpdatingHeading];

Before monitor the region I try to removed all the region which motinored before it. Then I monitored with region. But it will directly invote monitoringDidFailForRegion delegate method with Error: The operation couldn’t be completed. (kCLErrorDomain error 4.) error. And it will not called delegate method.

-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{

-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
}

Can anyone help me what is error in my code? Thanks,

Nirmalsinh Rathod
  • 5,079
  • 4
  • 26
  • 56
  • locationManager.delegate = self; – Rushabh Sep 13 '16 at 06:07
  • @Rushabh yes, delegate is already set at there. – Nirmalsinh Rathod Sep 13 '16 at 06:24
  • do you have implemented `requestAlwaysAuthorization`? http://stackoverflow.com/a/30728984/1702413 – TonyMkenu Sep 15 '16 at 07:21
  • @TonyMkenu Yes I did it. – Nirmalsinh Rathod Sep 15 '16 at 10:15
  • Your error mean `kCLErrorRegionMonitoringDenied` so you must check again if you don't have disabled "Background App Refresh" for the app in your device, if you have enabled Location Services. Reinstall the app and check if the app prompt the user to enable / allow the Location.... – TonyMkenu Sep 15 '16 at 14:09
  • @TonyMkenu I got one solution of my question. I stop all the location which is monitored before and then register with new one. It will solve fail monitor issue. But I got another one. Now it will not called didDetermineState method when app is in Background Mode. – Nirmalsinh Rathod Sep 19 '16 at 08:33

0 Answers0