很奇怪 didEnterRegion
和 didExitRegion
在 startMonitoringForRegion
被调用后从未被触发。此外,didDetermineState
可以按预期触发。
现阶段,我只评估基于Apple's sample code demo, Airlocated的iBeacon技术。 .
因此,我只在APLAppDelegate.m
文件中实现了didEnterRegion
和didExitRegion
两个方法,如下所示:
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region
{
NSLog(@"Entered region: %@", region);
[self sendLocalNotificationForBeaconRegion:(CLBeaconRegion *)region];
}
- (void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region
{
NSLog(@"Exited region: %@", region);
}
已尝试以下步骤,但没有效果。
- 用 iOS7.1 重置 iPhone5/iPhone4s
- 如下配置后台模式和*.plist:
- in project info or info.plist --> Custom IOS Target Properties --> . add "Required background modes" . in this add two items --> ."App shares data using CoreBluetooth" ."App registers for location updates"
- in project Capability --> There is Background Modes
. check "Loaction update"
. check "Acts as a Bluetooth LE accessory" . check "uses bluetooth LE accessories"
- 授权应用程序访问设备位置。
那么,有人可以给我一些建议吗?
提前致谢。
最佳答案
在startMonitoringForRegion
之后添加startRangingBeaconsInRegion
方法并重试
[_locationManager startRangingBeaconsInRegion:demoRegion];
//demoRegion - 你创建的区域
关于ios - iBeacon Bluetooth didEnterRegion 和 didExitRegion 方法永远不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24756019/