【发布时间】:2017-01-26 20:46:09
【问题描述】:
我正在为我的一个应用程序使用地理围栏。但我有一个问题。当应用程序处于 Background 模式时,我的应用程序未调用 - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region。
我在设置中检查 Background app refresh 标志是否为 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 设置正确。我对此进行了研究,但没有为我的问题得到适当的解决方案。谁能帮帮我?
谢谢
【问题讨论】:
标签: iphone cllocationmanager cllocation geofencing clregion