ios - iBeacon Bluetooth didEnterRegion 和 didExitRegion 方法永远不会触发

标签 ios objective-c bluetooth cllocationmanager ibeacon

很奇怪 didEnterRegiondidExitRegionstartMonitoringForRegion 被调用后从未被触发。此外,didDetermineState 可以按预期触发。

现阶段,我只评估基于Apple's sample code demo, Airlocated的iBeacon技术。 .

因此,我只在APLAppDelegate.m文件中实现了didEnterRegiondidExitRegion两个方法,如下所示:

- (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:
  1. 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"
  2. 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/

相关文章:

ios - 在 Swift 3 中按字母顺序排列两个字符串变量?

ios - 如何在保存之前自动设置计算的 NSManagedObject 属性?

iphone - 解析 Json 数组

ios - 应用无法找到音频蓝牙 HFP 免提端口 Swift

ios - LinkedIn SDK 比特码 iOS 9

ios - UITableView 的委托(delegate)类在 mvc 中的位置是什么?

iphone - 以编程方式检测 ScrollView 外的触摸

iphone - 应使用鼠标在特定区域移动图像

android - 蓝牙 : Transferring call from Source to sink?

ios - BLE(蓝牙4.0)中的即时警报服务和接近配置文件之间的关系是什么?