我必须使用estimote定位信标,iphone 5s,ios版本10。
didEnterRegion:也调用延迟30到40秒的方法。
我必须使用下面的代码来监控ibeacon。
NSUUID *uuid = [[NSUUID alloc] initWithUUIDString:@"CFC52BF4-FD33-4569-B4B5-5E9C220514A2"];
CLBeaconRegion *region = [[CLBeaconRegion alloc] initWithProximityUUID:uuid major:1 identifier:@"Technostacks23"];
region.notifyOnEntry = YES;
region.notifyOnExit = YES;
// launch app when display is turned on and inside region
region.notifyEntryStateOnDisplay = YES;
if ([CLLocationManager isMonitoringAvailableForClass:[CLBeaconRegion class]])
{
[_locationManager startMonitoringForRegion:region];
[_locationManager startRangingBeaconsInRegion:region];
}
[self.locationManager startUpdatingLocation];
#pragma mark - CoreLocation Delegate method
-(void)locationManager:(CLLocationManager *)manager didEnterRegion:(CLRegion *)region {
//local notification fire
}
-(void)locationManager:(CLLocationManager *)manager didExitRegion:(CLRegion *)region {
//local notification fire
}请各位告诉我如何处理这种情况。
谢谢
发布于 2016-11-05 22:23:37
我认为你不能在测距的同时监控一个地区。我在我制作的一个屏幕上遇到了这个问题,我想在屏幕上显示用户是否在Beacon的范围内。我不得不停止监控,直到他们离开屏幕,然后重新开始监控。如果您不需要用于测距的事件(用户与信标的距离有多近),我会将该行去掉,不需要获取-didEnter和-didExit调用。你也不应该需要-startUpdatingLocation。这仅适用于活动的位置呼叫。
入口事件通常会立即触发。一旦你失去对信标的信号,退出事件就会有20-30秒的延迟。
可能是你的后台运行时监控耗尽了,在你耗尽时间后,它停止了,为你打开了获得监控事件的大门。
发布于 2016-11-09 19:06:46
didEnterRegion委托方法中调用startRangingBeaconsInRegion方法,以便在信标还不在信标区域时,它不会覆盖信标。这将有助于降低功耗和电池消耗,我相信它会略微加快区域检测速度。但在所有情况下,30 - 40秒的延迟我发现这是正常的,这取决于已经在后台处理和耗尽资源的应用程序的数量,此外,根据您的应用程序模型,更好的做法是在几秒钟后开始通知区域进入,以确保他也在该区域,而不是如此迅速地通过“例如,我正在谈论一个超市模型”。
但如果这不是你的情况,你想通过路过检测一个地区,我认为你能得到的最快将是15 - 20秒,这取决于你的设备能力,速度,其他后台处理应用程序,以及信标广告时间间隔。
https://stackoverflow.com/questions/40438787
复制相似问题