我正在尝试开发应用程序,它的范围是CLBeaconRegion。
我看了WWDC的视频,主持人说,我应该打电话给startMonitoringForRegion,然后用户在区域内,startRangingBeaconsInRegion。我试过了。
if (!_locationManager) {
_locationManager = [[CLLocationManager alloc] init];
_locationManager.delegate = self;
_locationManager.desiredAccuracy = kCLLocationAccuracyBest;
}
CLBeaconRegion *targetRegion = [[CLBeaconRegion alloc] initWithProximityUUID:[[NSUUID alloc] initWithUUIDString:UUIDString] identifier:identifier];
targetRegion.notifyEntryStateOnDisplay = YES;
targetRegion.notifyOnEntry = YES;
targetRegion.notifyOnExit = YES;
[_locationManager startMonitoringForRegion:targetRegion];
[_locationManager startUpdatingLocation];但这并不意味着什么都不能委托。信标起作用了。
如果我打电话给
[_locationManager startRangingBeaconsInRegion:region];应用程序可以找到我周围所有的信标。
我应该打电话给第二种方法还是我错了?
你有什么建议吗?
发布于 2014-03-18 23:33:44
最有可能的解释是,您没有等待足够长的时间来接到您的代表的电话。当您不在范围内时,对下面的委托方法进行回调最多需要15分钟。当你在测距时,只需1秒。
- (void)locationManager:(CLLocationManager *)manager didDetermineState:(CLRegionState)state
- (void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region如果你等了15分钟,我想你会得到预期的回调。当您进行测距时,其速度要快得多的原因是因为iOS在启用ranging以查找iBeacons时会进行持续的蓝牙扫描。当你不测距,它减慢这些扫描,以节省电池。请参阅以下博客文章中的详细信息:
http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html
http://developer.radiusnetworks.com/2014/03/12/ios7-1-background-detection-times.html
https://stackoverflow.com/questions/22490921
复制相似问题