在iOS 10中测距信标

在我的应用程序中,我使用CoreLocation中的Beacon Region Monitoring。 该应用程序设置2 proximityUUID作为地区(他们有不同的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的错误吗?

好的,我在Swift 3中遇到了同样的问题,但是我解决了它。

似乎有两件事(可能是直接相关的):

  • 对于iOS10,信标的广告间隔可能会设置得太高(设置为200ms左右,然后根据Macrumors的dantastic的build议,它应该同时在9和10上工作)

  • 我如何得到它的工作:我testing了与iOS 9.3.5的iPad,并需要将部署目标更改为9.3。 这表明它正在我的iPad与iOS 9上再次工作,但是…也解决了我的iOS 10设备。