我正在开发一个信标应用程序。但是,当我需要将其他信标与不同的邻近UUID集成到我的应用程序中时。当我这样做时:
NSArray *uuids = [NSArray arrayWithObjects:@"####-####-###1", @"####-####-###2", nil];
for (NSString *uuidString in uuids) {
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:uuidString] identifier:identifier];
region.notifyOnEntry = entry;
region.notifyOnExit = exit;
region.notifyEntryStateOnDisplay = YES;
[_locationManager startMonitoringForRegion:region];
}
--------------------------------------
ESTBeaconRegion* region = [[ESTBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"F7826DA6-4FA2-4E98-8024-BC5B71E0893E"]identifier:@"EstimoteSampleRegion"];
ESTBeaconRegion* region1 = [[ESTBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:@"3A04104E-06E3-48BE-85D8-D0FF574FAE71"]identifier:@"EstimoteSampleRegion1"];
[self.beaconManager startRangingBeaconsInRegion:region];
[self.beaconManager startRangingBeaconsInRegion:region1];
它只能跟踪#2信标,因为#2会覆盖#1。那么有人能告诉我如何检测具有不同接近度UUID的信标吗?非常感谢!
答案 0 :(得分:1)
监控代码的问题在于它为每个区域使用相同的标识符字段。该字段必须是唯一的,否则第二个区域将覆盖第一个区域。尝试更改代码以使标识符保持唯一。像这样:
NSArray *uuids = [NSArray arrayWithObjects:@"####-####-###1", @"####-####-###2", nil];
for (NSString *uuidString in uuids) {
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:uuidString]
identifier:[NSString stringWithFormat:@"unique-identifier-for-uuid-%@",uuidString]];
region.notifyOnEntry = entry;
region.notifyOnExit = exit;
region.notifyEntryStateOnDisplay = YES;
[_locationManager startMonitoringForRegion:region];
}