我正在尝试唤醒我的应用程序(重新启动它),当它进入我定义的信标区域但我无法让它工作.这是我正在使用的步骤和代码.
将"位置更新"背景模式设置为YES.
监控我的CLBeaconRegion
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"EBEFD083-70A2-47C8-9837-E7B5634DF524"]; beaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:@"daRegion"]; beaconRegion.notifyEntryStateOnDisplay = NO; beaconRegion.notifyOnEntry = YES; beaconRegion.notifyOnExit = YES; self.locationManager = [[CLLocationManager alloc] init]; self.locationManager.delegate = self; [self.locationManager startMonitoringForRegion:beaconRegion];
实现委托方法
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region; - (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region;
我可能遗失的任何东西?我已阅读文档,博客文章,论坛,似乎没有任何工作.这是我读过的网站之一,这是另一个.
评论"当应用程序被杀时我无法使其正常工作"至关重要.
如果您使用iOS7应用程序切换器来杀死应用程序(例如,通过向上滑动应用程序图标),那么在进入或离开iBeacon区域时,您将无法在后台重新启动应用程序.这是设计 - 如果用户不希望应用程序运行,那么Apple认为代码不应该能够重新启动它. 看到这个帖子.
幸运的是,用户通常不这样做.出于测试目的,如果要完全停止应用程序,请不要这样做.重新启动手机.(但请注意,启动后需要一分钟左右才能检测到iBeacons.)
编辑2014/03/10:自iOS 7.1发布以来,此行为已发生变化.从任务切换器中杀死应用程序不再阻止它在后台检测到iBeacons.