我有一个关于iBeacon监控实现的问题。当locationManager:didDetermineState:forRegion:方法被调用时,我会触发一个本地通知。当应用程序在后台运行时,我根本不会收到任何本地通知,但当我激活屏幕并按下主页按钮时,所有这些通知都会立即出现。根据我离开休眠设备的时间,当我唤醒它时,我可以收到多达十个通知。那件事怎么可能?有没有人有同样的问题?
我在iOS 7.1上使用iPhone 5S和5C。本地通知的设置方式如下:
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{
UILocalNotification *localNot = [[UILocalNotification alloc] init];
localNot.alertBody = [NSString stringWithFormat:@"Region state %d determined", state];
localNot.alertAction = @"Go for it!";
localNot.soundName = UILocalNotificationDefaultSoundName;
localNot.fireDate = nil;
[[UIApplication sharedApplication] presentLocalNotificationNow:localNot];
}发布于 2014-03-18 02:21:44
我怀疑您实际上根本没有执行任何后台检测,当您点击主页按钮时看到通知的原因是因为您设置了notifyEntryStateOnDisplay标志,这会导致您在屏幕打开时为您正在监视的每个设置了标志的区域获得额外的didDetermineState: forRegion:回调。
为什么你没有在后台得到回调?您可能需要等待15分钟才能在后台检测到iBeacon,即使在iOS 7.1上也是如此。参见here。
https://stackoverflow.com/questions/22461036
复制相似问题