【发布时间】:2017-01-13 08:52:46
【问题描述】:
在我的应用程序中,我在 CoreLocation 中使用 Beacon 区域监控。 该应用程序将 2 个邻近 UUID 设置为区域(它们具有不同的 id), 并像下面一样开始测距。
#pragma mark - CLLocationManagerDelegate
(void)locationManager:(CLLocationManager *)manager
didEnterRegion:(CLRegion *)region {
[self.locationManager requestStateForRegion:(CLBeaconRegion *)region];
}
- (void)locationManager:(CLLocationManager *)manager
didExitRegion:(CLRegion *)region {
[self.locationManager stopRangingBeaconsInRegion:(CLBeaconRegion *)region];
}
- (void)locationManager:(CLLocationManager *)manager
didRangeBeacons:(NSArray *)beacons inRegion:(CLBeaconRegion *)region{
for(CLBeacon* b in beacons){
//output only previous beacon if it's before regionout to previous region
NSLog(@"%@",b);
}
}
- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error {
//error
}
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region{
if(state == CLRegionStateInside){
if ([region isMemberOfClass:[CLBeaconRegion class]] && [CLLocationManager isRangingAvailable]){
[self.locationManager startRangingBeaconsInRegion:(CLBeaconRegion *)region];
}
}
}
它适用于 iOS 8 和 iOS 9,但不适用于 iOS 10。
[在 iOS 8/iOS 9 中]
1.broadcast beacon1
2.[app]didRangeBeacons (beacon1)
3.stop beacon1 and broadcast beacon2
4.[app]didRangeBeacons (beacon2)
[iOS 10]
1.broadcast beacon1
2.[app]didRangeBeacons (beacon1)
3.stop beacon1 and broadcast beacon2
4.[app]didRangeBeacons (**beacon1**)
这是 iOS 10 的错误吗?
【问题讨论】:
-
在 iOS 10 中,信标测距似乎确实有些不同。我得到了非常不一致的结果,信标短暂显示,然后再也没有在 didRangeBeacons 函数中测距。
-
感谢您的试用和信息!我正在等待更新解决...
-
您是否为此问题提交了雷达?
-
也许你应该在 iOS 10.1b2 上试试。我在 iOS 10.0.x 中遇到了不同的信标问题(没有触发区域退出事件)。这个接缝将在最新的 IOS 测试版中修复。
-
安装 10.0.3 (14A551) 后 iBeacon 问题较少
标签: ios objective-c bluetooth core-location ios10