CLLocationManager didDetermineState方法不在应用程序在后台时调用
问题描述:
我正在使用Geofencing为我的应用程序之一。但是我有一个问题。我的应用程序不叫- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region当应用程序在背景模式。CLLocationManager didDetermineState方法不在应用程序在后台时调用
我检查了后台程序刷新标志是ON在设置中。
下面是我的代码:
- (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设置正确。我研究它,但没有得到适当的解决我的问题。任何人都可以帮助我吗?
谢谢