我正在使用 Geofencing 作为我的某个应用程序。但我有一个问题。当应用程序处于后台模式时,我的应用程序不会被称为 - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)stateRegion:(CLRegion *)region 。
我在设置中检查后台应用刷新标志是开启。
以下是我的代码:
- (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 已正确设置。我研究它,但没有得到适当的解决我的问题。任何人都可以帮助我吗?
由于