使用不同的UUID检测iBeacon

我试图使用UUID作为特定信标的标识符(在这种情况下使用电话)。 我明白,主要和次要的是用来做到这一点,但我宁愿使用UUID,或标识符string。

这样说,有无论如何扫描信标,无论使用CLBeacon API的UUID?

在Android上,您可以扫描所有UUID。 在iOS上,你不能。 看到:

http://developer.radiusnetworks.com/2013/10/21/corebluetooth-doesnt-let-you-see-ibeacons.html

在iOS上,CoreLocation限制您监视至多20个不同的UUID。 测距没有20的限制,但你仍然必须提前知道UUID。

据我所知,监控不同UUID的iBeacon区域没有限制。 你可以做一些事情:

NSArray *uuids = [NSArray arrayWithObjects:@"####-####-###1", @"####-####-###2", nil]; for (NSString *uuidString in uuids) { CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:uuidString] identifier:identifier]; region.notifyOnEntry = entry; region.notifyOnExit = exit; region.notifyEntryStateOnDisplay = YES; [_locationManager startMonitoringForRegion:region]; } 

你只需要确保你在locationManager的委托方法中检查UUID。 你可以使用这样的东西:

 - (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state forRegion:(CLRegion *)region { if ([region isKindOfClass:[CLBeaconRegion class]]) { CLBeaconRegion *beaconRegion = (CLBeaconRegion *)region; NSLog(@"ProximityUUID:%@", beaconRegion.proximityUUID); NSLog(@"ProximityMajor:%@", beaconRegion.major); NSLog(@"ProximityMinorD:%@", beaconRegion.minor); } } 

你应该看到委托方法被调用了不同的UUID。

希望这可以帮助。