首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >CLLocationManager + CLBeaconRegion监控

CLLocationManager + CLBeaconRegion监控
EN

Stack Overflow用户
提问于 2014-03-18 20:58:58
回答 1查看 928关注 0票数 2

我正在尝试开发应用程序,它的范围是CLBeaconRegion。

我看了WWDC的视频,主持人说,我应该打电话给startMonitoringForRegion,然后用户在区域内,startRangingBeaconsInRegion。我试过了。

代码语言:javascript
复制
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];

但这并不意味着什么都不能委托。信标起作用了。

如果我打电话给

代码语言:javascript
复制
[_locationManager startRangingBeaconsInRegion:region];

应用程序可以找到我周围所有的信标。

我应该打电话给第二种方法还是我错了?

你有什么建议吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-18 23:33:44

最有可能的解释是,您没有等待足够长的时间来接到您的代表的电话。当您不在范围内时,对下面的委托方法进行回调最多需要15分钟。当你在测距时,只需1秒。

代码语言:javascript
复制
- (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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22490921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档