iBeacon在后台测距? [英] iBeacon ranging in the background?

查看:212
本文介绍了iBeacon在后台测距?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始使用estimotes作为信标来测试iBeacons。

I have started to test out iBeacons using estimotes as beacons.

这一切都运行得很好,但是我很难让应用程序正常运行背景。

It's all running pretty good, but i'm struggling with getting the app to run properly in the background.

self.region = [[CLBeaconRegion alloc] initWithProximityUUID:self.uuid identifier: self.deviceID];
self.region.notifyEntryStateOnDisplay = YES;
[self.locationManager startMonitoringForRegion:self.region];

所以这是基本设置,对于我的测试应用程序,我想在我的手机上显示本地通知就在灯塔附近。我的问题是,除非我在下面包含这一行,否则它将无效。

So this is the basic setup and for my test app i want to show a local notification when my phone is in immediate proximity of the beacon. My problem is that it won't work unless i include the line below.

[self.locationManager startUpdatingLocation];

任何人都能解释为什么会这样或者我错过了关于iBeacons的东西吗?

Can anyone explain why that is or if i'm missing something about iBeacons?

推荐答案

你错了。您无需调用startUpdatingLocation即可在后台调用。

You are mistaken. You don't need to call startUpdatingLocation in order to be called in the background.

当您在后台时,进入某个地区时需要更长时间才能收到通知。如果你想要测距调用,你也必须发出startRangingBeaconsInRegion调用。正如另一张海报指出的那样,当检测到新的信标时,您只能从后台获得几秒的测距呼叫。 (你得到一个didEnterRegion,然后是几个测距调用,然后你的应用程序就会重新入睡。)

When you're in the background it takes longer to get notified when you enter a region. If you want ranging calls, you have to issue the startRangingBeaconsInRegion call as well. As the other poster pointed out, you will only get a few seconds of ranging calls from the background when a new beacon is detected. (You get a didEnterRegion, followed by a few ranging calls, and then your app goes back to sleep.)

这篇关于iBeacon在后台测距?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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