4

这是我的代码:

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

澄清一下,“_serviceUUIDs”是一个包含五个 UUID 的 NSStrings 的 NSArray。我正在使用 Locate iBeacons 进行测试,发现要添加的最后一个区域是唯一被检测到的区域。它似乎也是唯一被监控的。我通过检查"_locationManager.monitoredRegions"确定了这一点。

这里有许多线程说可以监视多个信标区域。有人对为什么它不适合我有想法吗?谢谢!

4

1 回答 1

13

可以监控多个区域,但每个区域必须有一个唯一的identifier. 看起来您正在SERVICE_IDENTIFIER为每个区域传递相同的常量。尝试将其设置为每个值的唯一值。

于 2014-01-23T20:46:12.923 回答