即使应用程序位于同一位置,信标的接近范围也会来回变化 [英] Proximity range for Beacons changes back and forth even when the App is in the same place

查看:131
本文介绍了即使应用程序位于同一位置,信标的接近范围也会来回变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Beacon接近范围将接近响应更改为Near - Immediate - Far,即使ios设备保持在同一位置。

Beacon Proximity range changes the proximity response as Near - Immediate - Far, even while the ios Device remains in the same place.

当我打开视图时接近响应是近。我来回接近接近响应,接近 - 立即接近。它一次又一次地显示视图

As I open a view when the proximity response is Near. I get the proximity response back and forth, Near - immediate then Near. It shows up the view again and again

我们如何解决这个问题。是否有任何事件处理程序。

How can we solve this issue. Is there any event handler.

谢谢。

推荐答案

接近和准确度值似乎非常'嘈杂'。它还可以取决于您的环境。水(因此人们)吸收蓝牙使用的频率,因此人们移动可能会产生影响,但是当两台设备都放在我的桌子上时,我观察到1.2米到1.9米之间的变化。

The proximity and accuracy values appear to be quite 'noisy'. It can also depend on your environment. Water (and therefore people) absorbs the frequencies used by Bluetooth so people moving can have an impact, but I observe variation in between 1.2m and 1.9m when both devices are sitting on my desk.

我认为你将不得不处理你的应用程序中的噪音。一旦视图打开,您应该保持打开,直到信标远(或者您获得区域退出)一段时间。如果状态转换回近或立即重置计时器。

I think you are going to have to deal with the noise in your app. Once a view has opened you should keep it open until the beacon is 'far' (or you get a region exit) for some period of time. If the state transitions back to near or immediate then reset the timer.

您需要使用类似以下的代码 -

You need to use some code similar to the following -

-(void)locationManager:(CLLocationManager *)manager
    didRangeBeacons:(NSArray *)beacons
           inRegion:(CLBeaconRegion *)region {

    CLBeacon *beacon=beacons[0];

    switch (beacon.proximity) {

    case CLProximityFar:
        if (self.farTimer==nil) {
            self.farTimer=[NSTimer scheduledTimerWithTimeInterval:30 target:self selector:@selector(farTimerFired:) userInfo:beacon repeats:NO];
        }
    break;

    case CLProximityNear:
    case CLProximityImmediate:
        if (self.farTimer!=nil) {
            [self.farTimer invalidate];
            self.farTimer=nil;
        }
    break;

    case CLProximityUnknown:
         NSLog(@"Beacon proximity is unknown");
    break;
   }
}

-(void) farTimerFired:(NSTimer *)timer {
 CLBeacon *beacon=(CLBeacon *)timer.userInfo;
 NSLog(@"Beacon %@ is really far",beacon.proximityUUID.UUIDString);
 self.farTimer=nil;
}

这篇关于即使应用程序位于同一位置,信标的接近范围也会来回变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆