Monitoring multiple beacon regions is not working yet developers have said it's possible? Thoughts? (See my code)

StackOverflow https://stackoverflow.com/questions/21318844

Question

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!

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top