IBeacon背景监控 [英] IBeacon background monitoring

查看:78
本文介绍了IBeacon背景监控的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,其核心功能需要信标监控.确切地说,我需要将每个具有特定UUID的信标的有效负载(最小范围)值添加到核心数据列表(如果我可以设置信标需要保持一定时间的阈值,那会更好.在将其添加到列表之前).我一直在寻找解决方案,但这有点版本混乱,我无法真正确定我所需要的是否可行.我发现了

I'm building an app which's core functionality requires beacon monitoring. To be exact I need to add the payload (min range) value of every beacon with a specific UUID to a Core Data list(it would be even better if I could set a certain threshold of time in which the beacon needs to stay in reach before it gets added to the list). I've been looking for solutions, but it's a bit of a version mess and I can not really tell if what I need is possible. I've found this article, according to which I can get an event triggered in the background, or use Background Modes. My question is if this is still true and if so if anybody has resources concerning the use of Background Models combined with IBeacon.

德国人的礼物!

推荐答案

Apple限制了iOS应用在后台定位"信标的持续时间.截至2020年4月,情况确实如此,过去5-6年的事态基本没有变化.

Apple restricts the duration in which iOS apps may "range" beacons in the background. This is true as of April 2020, and the state of affairs is largely unchanged in the last 5-6 years.

一些说明:

  1. 信标监控在后台不受限制,前提是用户向应用授予始终定位"权限.但是信标监视仅为您提供进入"和退出"事件..当您要查找的任何信标首次出现时,它为您提供一个进入事件,而当您最后一个信标出现时,它为您提供一个退出事件.寻找消失.监视不会告诉您有关单个信标的估计距离或信号强度的任何信息.

  1. Beacon monitoring is not restricted in the background, provided the user grants "location always" permission to the app. But beacon monitoring only gives you "entry" and "exit" events. It gives you an entry event when any beacon you are looking for first appears, and an exit event when the last of the beacons you are looking for disappears. Monitoring won't tell you anything about the estimated distance or signal strength of an individual beacon.

信标范围,您可以每秒获取更新,其中包含可见的所有信标列表,每个信标的信号强度和距离估计.距离估算值处于一定阈值以下.

Beacon ranging lets you get updates every second with a list of all beacons visible, each beacon's signal strength and a distance estimate. You can easily program logic to write to a database if the distance estimate is under as certain threshold.

信标范围在后台受到限制.首先,用户必须授予始终定位"访问您的应用的权限.而且即使如此,您也只能在应用程序进入后台后才进行大约5-10秒的测距,或者信标在后台运行后才首次出现.

Beacon ranging is restricted in the background on iOS. First, the user must grant "location always" access to your app. And even then you are limited to about 5-10 seconds of ranging after your app goes to a background, or beacons first appear after it is in the background.

您只需按照

You can extend the 5-10 seconds mentioned in (3) to 180 seconds simply by running a background task per my blog post here.

如果您在Info.plist中声明位置"后台模式,请按照(4)所述使用后台任务,然后使用CoreLocation,则可以进一步无限期延长180秒 请求位置更新(为此,只有3 km分辨率的粗略位置更新可以正常工作,并且可以通过关闭GPS来节省电池电量.)

You can further extend the 180 seconds indefinitely if you declare "location" background mode in your Info.plist, use a background task as described in (4), and you use CoreLocation to request location updates (coarse location updates with only a 3km resolution work fine for this purpose and save battery by keeping the GPS off.)

(5)的一个问题是,如果您打算将其提交到App Store,那么它可能会导致您的应用被拒绝,并且您在使用后台位置方面没有明显的面向用户的好处.如果您确实有充分的道理,或者打算将应用程序分发到App Store之外(例如公司企业应用程序),则可以正常使用.

One problem with (5) is that it may get your app rejected if you plan to submit it to the App Store and you don't provide an obvious user-facing benefit to using location in the background. If you do have a good justification, or you intend to distribute the app outside the App Store (e.g. a corporate enterprise app), then this will work fine.

(5)的第二个问题是,始终保持量程变化会导致大量电池消耗.您可能需要编程额外的逻辑以在不需要的时候停止恒定的背景测距,以节省电池电量.

A second problem with (5) is that ranging all the time can cause significant battery drain. You may need to program extra logic to stop this constant background ranging at times where it is not needed in order to save battery.

这无疑是令人困惑和复杂的.但最重要的是,有多种方法可以无限期地覆盖信标,从而满足许多用例.您只需要跳过一些箍就可以实现它.

This is admittedly confusing and complex. But the bottom line is that there are ways to range beacons indefinitely to satisfy many use cases. You just have to jump through some hoops to make it happen.

这篇关于IBeacon背景监控的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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