【发布时间】:2014-04-04 13:44:08
【问题描述】:
我正在尝试使用 CoreLocation 来获取我的 iOS 应用程序指定的多个 iBeacons - 我的想法是,如果它们在范围内,它会在找到它们时通知我。
问题是在 didEnterRegion 和 didExitRegion 方法中,我必须提供一个 CLBeaconRegion 对象。每个 iBeacon 都有一个,如果我只使用一个 iBeacon,我可以只使用那个,但由于有多个,我需要知道如何从这些方法中找到每个 CLBeaconRegion。
也许我误解了它的工作原理;如果有,请告诉我。
- (void)getForUUUIDs:(CDVInvokedUrlCommand *)command
{
//Get an array of UUID's to filter by
self->locationUUIDs = [self getArgsObject:command.arguments];
self->locationManager = [[CLLocationManager alloc] init];
self->locationManager.delegate = self;
scanCallback = command.callbackId;
for(NSInteger i = 0; i < [locationUUIDs count]; i++) {
NSString *identifier = [NSString stringWithFormat:@"BLERegion %d",i];
CLBeaconRegion *thisRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[locationUUIDs allKeys] objectAtIndex:i] identifier:identifier];
[self->locationManager startMonitoringForRegion:thisRegion];
}
}
- (void)locationManager:(CLLocationManager*)manager didEnterRegion:(CLRegion*)region
{
[self->locationManager startRangingBeaconsInRegion:????];
}
-(void)locationManager:(CLLocationManager*)manager didExitRegion:(CLRegion*)region
{
[self->locationManager stopRangingBeaconsInRegion:????];
}
【问题讨论】:
-
您真的需要多个 UUID 吗?使用 Major/Minor 演奏会很多轻松。
-
你误会了。我们的客户会将他们使用的 UUID 输入到我们的系统中,应用程序将报告设备可以检测到哪些 UUID。我目前对位置不感兴趣,我只是收集信息并将其发送回去。我什至不知道他们会使用什么 iBeacon。
标签: ios objective-c core-location ibeacon