Search code examples
iosuuidibeaconlocationmanager

startRangingBeaconsSatisfyingConstraint multiple beacons


When i use startRangingBeaconsInRegion with different regions didRangeBeacons inRegion can determine all the beacons that i set, but when i am doing the same with startRangingBeaconsSatisfyingConstraint didRangeBeacons satisfyingConstraint can determine only the last one. Is it the apple bug?

startRangingBeaconsInRegion

for (NSString *uuidString in uuidsString) {
    NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];

    CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithUUID:uuid identifier:uuidString];
    [_locationManager startRangingBeaconsInRegion:region];
}

startRangingBeaconsSatisfyingConstraint

for (NSString *uuidString in uuidsString) {
    NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:uuidString];        

    CLBeaconIdentityConstraint *beaconIdentityConstraint = [[CLBeaconIdentityConstraint alloc] initWithUUID:uuid];
    [_locationManager startRangingBeaconsSatisfyingConstraint:beaconIdentityConstraint];
}

Solution

  • This appears to be a recently introduced bug in CoreLocation with the new startRangingBeaconsSatisfyingConstraint API.

    The workaround for now is to use the deprecated startRangingBeaconsInRegion API.

    See related post here:

    SWIFT: CoreLocation - Ranging Beacons using CLBeaconIdentityConstraint does not range multiple beacons

    And the Apple forum post reporting the bug:

    https://forums.developer.apple.com/thread/130360