Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 513
mr.sosa Avatar asked Dec 11 '22 08:12

mr.sosa


1 Answers

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.

like image 62
James Frost Avatar answered Feb 15 '23 23:02

James Frost