【发布时间】:2014-07-22 21:09:25
【问题描述】:
我编写了一个小型 iBeacon 演示应用程序,它可以检测信标范围,然后在第一次发现信标后监控范围内的信标。运行此应用程序后(如果它仍在后台),我发现设备无法建立新的蓝牙连接。例如,当我进入我的汽车时,我的汽车会无限尝试连接手机,但没有成功,直到我关闭并再次打开蓝牙。这似乎是在离开 iBeacons 区域后保持蓝牙处于活动状态的问题,但我已停止在 didExitRegion 上搜索信标。我什至尝试在视图消失或应用程序关闭时停止对信标的测距。为了在离开范围时正确关闭连接,是否需要采取其他步骤?
编辑:我只说在 OP 中进行测距,但我也确保在应用程序处于非活动状态和退出区域时停止监视信标区域。问题依旧
编辑 2:如果我必须说预期的特定行为,我希望能够在应用程序运行和后台运行时对信标进行范围和监控,而不会停止其他蓝牙连接。实际行为是它在这些情况下会跟踪信标,但不允许形成其他蓝牙连接。
初始化和开始监测信标的代码(在 viewDidLoad 中):
if (self.beaconManager == nil) {
self.beaconManager = [[ESTBeaconManager alloc] init];
self.beaconManager.delegate = self;
}
if (self.icyMarshmallowRegion == nil) {
self.icyMarshmallowRegion = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:[kIcyMarshmallowMajor integerValue] minor:[kIcyMarshmallowMinor integerValue] identifier:kIcyMarshmallowRegionID];
self.icyMarshmallowRegion.notifyOnEntry = YES;
self.icyMarshmallowRegion.notifyEntryStateOnDisplay = YES;
}
[self.beaconManager startMonitoringForRegion:self.icyMarshmallowRegion];
停止监控的代码(在 didExitRegion 中):
[self.beaconManager stopMonitoringForRegion:self.icyMarshmallowRegion];
【问题讨论】:
-
你用的是哪个版本的IOS?
-
@Macistador 最新的非测试版 (7.1.2)。我没有可用于测试这是否是已在更新中解决的系统问题的 iOS 8 设备。
标签: ios bluetooth ibeacon connectivity