这是我的代码:
// Initialize and monitor regions
for (NSString *serviceUUID in _serviceUUIDs) {
// Initialize region
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:serviceUUID];
CLBeaconRegion *appBeaconRegion = [[CLBeaconRegion alloc] initWithProximityUUID:uuid identifier:SERVICE_IDENTIFIER];
// Specify notifications
appBeaconRegion.notifyEntryStateOnDisplay = YES;
appBeaconRegion.notifyOnEntry = YES;
appBeaconRegion.notifyOnExit = YES;
// Add to regions
[_appBeaconRegions addObject:appBeaconRegion];
// Begin monitoring region and ranging beacons
[_locationManager startMonitoringForRegion:appBeaconRegion];
[_locationManager startRangingBeaconsInRegion:appBeaconRegion];
}
澄清一下,“_serviceUUIDs”是一个包含五个 UUID 的 NSStrings 的 NSArray。我正在使用 Locate iBeacons 进行测试,发现要添加的最后一个区域是唯一被检测到的区域。它似乎也是唯一被监控的。我通过检查"_locationManager.monitoredRegions"确定了这一点。
这里有许多线程说可以监视多个信标区域。有人对为什么它不适合我有想法吗?谢谢!