在iOS7.1中,当用户杀死一个应用程序时,地理围栏还能工作吗?
如果地理围栏检测到设备正在进入或退出区域,它是否可以触发本地通知(即使用户已经关闭了应用程序)?
发布于 2014-03-20 09:35:29
你的GeoFencing仍然可以工作,它的工作原理就像推送通知/或者存折一样,它仍然会为你的应用生成通知。即使应用程序不在后台运行,bellow函数也会触发。
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
NSString *event = [NSString stringWithFormat:@"didExitRegion %@ at %@", region.identifier, [NSDate date]];
[self updateWithEvent:event];
//implement local notification:
UIApplication *app = [UIApplication sharedApplication];
UILocalNotification *notification = [[UILocalNotification alloc] init];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
if (notification == nil)
return;
notification.alertBody = [NSString stringWithFormat:@"Did You Lock Your House?"];
notification.alertAction = @"Lock House";
notification.soundName = UILocalNotificationDefaultSoundName;
notification.applicationIconBadgeNumber = 1;
[app presentLocalNotificationNow:notification];
[notification release];
}https://stackoverflow.com/questions/22521684
复制相似问题