在我的应用程序中,我使用CoreLocation中的Beacon区域监控。应用程序设置了2个不同ID的ProximityUUID作为区域,并像以下方式一样开始范围测量。
#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是否有bug?