I am using Geofencing for one of my application. But I got one issue in it. My application is not called - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region when application is in Background mode.
I check for Background app refresh flag is ON in settings.
Below is my code:
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region
if (state == CLRegionStateInside)
{
NSLog(@"is in target region");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"You are IN of REGION";
notification.fireDate = [NSDate date];
NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
notification.timeZone = timezone;
notification.alertAction = @"Show";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
else
{
NSLog(@"is out of target region");
UILocalNotification *notification = [[UILocalNotification alloc] init];
notification.alertBody = @"You are OUT of REGION";
notification.fireDate = [NSDate date];
NSTimeZone* timezone = [NSTimeZone defaultTimeZone];
notification.timeZone = timezone;
notification.alertAction = @"Show";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
}
CLLocationManager is set properly. I reseach on it, but didn't get proper soluction for my proble. Can anyone help me in it?
Thanks
I solved my issue. It's because I have marked Location Update in backgournd.