【问题标题】:iBeacon Bluetooth didEnterRegion and didExitRegion methods are never firediBeacon 蓝牙 didEnterRegion 和 didExitRegion 方法永远不会被触发
【发布时间】:2014-07-15 10:37:28
【问题描述】:

很奇怪,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 如下:
  1. 在项目信息或 info.plist --> 自定义 IOS 目标属性 --> .添加“所需的背景模式” .在此添加两个项目--> ."App 使用 CoreBluetooth 共享数据" .“应用注册位置更新”
  2. 在项目能力--> 有背景模式
    .检查“位置更新”
    .选中“充当蓝牙 LE 附件” .勾选“使用蓝牙 LE 配件”
  • 授权应用程序访问设备位置。

那么,谁能给我一些建议?

提前致谢。

【问题讨论】:

  • 尝试添加 region.notifyOnEntry = YES; region.notifyOnExit = YES;创建 CLBeaconRegion 之后。
  • 感谢您的及时反馈,试用后很快就会更新状态。
  • Greg,将参数指定为“region.notifyOnEntry = YES; region.notifyOnExit = YES”后似乎没有效果
  • 谢谢,格雷格。这是我第一次提出问题,而您是第一个在 stackoverflow.com 上给我回复的人。 ^_^^_^^_^^_^^_^^_^ 是时候为我离开办公室了。贝。

标签: ios objective-c bluetooth cllocationmanager ibeacon


【解决方案1】:

在startMonitoringForRegion之后添加startRangingBeaconsInRegion方法并重试

[_locationManager startRangingBeaconsInRegion:demoRegion]; // demoRegion - 你创建的区域

【讨论】:

  • 亚历克斯,感谢您的建议。我会在尝试后添加结果。顺便说一句,测距 API 在之前的验证中正常工作。
  • 哇!!!!!!!!!!根据您的建议,监控 API 可以正常工作。非常感谢!^_^^_^^_^^_^^_^^_^^_^^_^^_^你怎么知道??????我看到你在苹果帮助文档中指出的相关描述????
  • 是的,刚刚在developer.radiusnetworks.com/2013/11/13/…David G.Young 的注释中得到了关于为什么在 startMonitoringForRegion 之后添加 startRangingBeaconsInRegion 方法的解释。
猜你喜欢
  • 2013-12-28
  • 2013-12-13
  • 2015-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-06-12
  • 2016-07-24
  • 2014-09-30
相关资源
最近更新 更多