在iOS7.1中用户杀死App时进行地理围栏

时间:2014-03-20 01:29:05

标签: ios objective-c

在iOS7.1中,当用户杀死某个应用时,地理围栏是否仍有效?

如果地理围栏检测到设备正在进入或退出该区域,它是否可以触发本地通知(即使用户已杀死该应用)?

1 个答案:

答案 0 :(得分:1)

你GeoFencing仍然可以工作,就像推送通知/或存折一样,它仍会为你的应用程序生成通知。即使app未在后台运行,波纹管功能也会触发。

    - (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];

}
相关问题