我正在尝试检测多个iBeacons.我已经在他们附近放了三个iBeacons.
问题是逐一检测.不在数组中.它应该返回3个iBeacons.
self.beaconManager = [[ESTBeaconManager alloc] init]; self.beaconManager.delegate = self; self.region1 = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID major:21668 minor:53482 identifier:@"EstimoteSampleRegion"]; self.region2= [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_MACBEACON_PROXIMITY_UUID major:3894 minor:57726 identifier:@"EstimoteSampleRegion2"]; self.region3= [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_IOSBEACON_PROXIMITY_UUID major:13067 minor:31901 identifier:@"EstimoteSampleRegion3"]; [self.beaconManager startRangingBeaconsInRegion:_region1]; [self.beaconManager startRangingBeaconsInRegion:_region3]; [self.beaconManager startRangingBeaconsInRegion:_region2];
//委托方法
-(void)beaconManager:(ESTBeaconManager *)manager didRangeBeacons:(NSArray *)beacons inRegion:(ESTBeaconRegion *)region { //checks bRegion, so you could have it searching for other beacons if you wanted after one is notified NSLog(@"Start"); for (ESTBeacon *iBeacon in beacons) { NSLog(@"%@",iBeacon.minor); } NSLog(@"Finish"); }
控制台O/p
Start 57726 Finish Start 53482 Finish Start 31901 Finish Start 57726 Finish
Paulw11.. 6
如果你看一下方法签名,你会发现 -
didRangeBeacons:inRegion:
请注意'inRegion' - 您的三个信标位于不同的区域,因此您可以为每个区域拨打个人电话.
如果您将区域初始化更改为 -
self.region1 = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID identifier:@"EstimoteSampleRegion"];
并删除其他两个区域,然后您将收到同一区域内所有三个信标的通知.您需要分别检查每个主要和次要,以确定哪个是哪个.
如果您将所有信标都设为相同的专业,那么您可以指定您所在地区的专业,并且您只会收到"您的"信标通知,而不是所有Estimote信标(除非其他人选择相同的专业...)
如果你看一下方法签名,你会发现 -
didRangeBeacons:inRegion:
请注意'inRegion' - 您的三个信标位于不同的区域,因此您可以为每个区域拨打个人电话.
如果您将区域初始化更改为 -
self.region1 = [[ESTBeaconRegion alloc] initWithProximityUUID:ESTIMOTE_PROXIMITY_UUID identifier:@"EstimoteSampleRegion"];
并删除其他两个区域,然后您将收到同一区域内所有三个信标的通知.您需要分别检查每个主要和次要,以确定哪个是哪个.
如果您将所有信标都设为相同的专业,那么您可以指定您所在地区的专业,并且您只会收到"您的"信标通知,而不是所有Estimote信标(除非其他人选择相同的专业...)