Here's my code:
// 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];
}
To clarify, "_serviceUUIDs" is an NSArray of NSStrings containing five UUIDs. I'm using Locate iBeacons for testing and have found that the last region to be added is the only one that is detected. It also appears to be the only one being monitored. I determined this by checking "_locationManager.monitoredRegions".
There are a number of threads on here saying it's possible to monitor multiple beacon regions. Any one have thoughts for why it's not working for me? Thanks!
You can monitor multiple regions, but each region must have a unique identifier
. It looks like you're passing in the same constant SERVICE_IDENTIFIER
for each region. Try setting that to a unique value for each one.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With