小编t_m*_*_ms的帖子

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];
        }
  } …
Run Code Online (Sandbox Code Playgroud)

bluetooth objective-c core-location ios ios10

8
推荐指数
1
解决办法
2572
查看次数

标签 统计

bluetooth ×1

core-location ×1

ios ×1

ios10 ×1

objective-c ×1