Question

I am now developing an beacon app. But when I need to integrate other beacons with different proximity UUIDs into my app. When I do as follows:

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];

it can only track #2 beacons, because #2 overwrite #1. So could anyone tell me how to detect beacons with different proximity UUIDs? Thanks a lot!

Was it helpful?

Solution

The problem with the monitoring code is that it is using the same identifier field for each region. This field must be unique, otherwise the second region will overwrite the first. Try changing the code to keep the identifier unique. Like this:

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];
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top