如何在后台检测ibeacon设备 [英] How to detect ibeacon device in background

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

问题描述

我正在实施基于通知的ibeacon应用程序.我要尝试的操作与视频完全相同( https://www.youtube.com/观看?v = SrsHBjzt2E8 ).用户从Appstore下载该应用程序,看一看,然后将其推向后台.假设用户正在家里做所有事情.后来,用户在应用程序处于后台模式时在安装的ibeacon商店中走来走去,我期望该应用程序会自动检测到ibeacon设备并得到通知.但是,区域测距和监视应该是在FOREGROUND中首先检测附近的信标设备的方法.那就是IOS 7中的当前限制.

I am implementing notification-based ibeacon app. What I am trying to do is exactly same as the video(https://www.youtube.com/watch?v=SrsHBjzt2E8). A user download the app from Appstore, take a look and then push it background. Supposed the user was doing whole things at home. Later, the user walk around the store ibeacon installed while the app is in background mode.What I expected is that the app automatically detect ibeacon devices and get notified. However,region ranging and monitoring should be the first to detect beacon devices nearby in FOREGROUND. Thats the current limitation in IOS 7.

在没有让用户将应用程序置于前台并单击按钮以开始测距和监视的情况下,有没有人有过如何检测ibeacon设备的经验?.

Does anyone have experience on how to detect ibeacon devices without letting a user bring the app into the foreground and click the button to start ranging and monitoring?..

谢谢

推荐答案

您可以使用CoreLocation信标监视API在后台检测信标-它的工作方式与在前台相同,并且是自动的.您无需进行任何特殊配置即可进行设置.

You can use the CoreLocation beacon monitoring APIs to detect beacons in the background -- it works the same way as in the foreground, and is automatic. You don't need to do any special configuration to set it up.

您的应用程序首次运行并设置监视区域时,CoreLocation会记住该区域,即使您的手机重启或您的应用程序不再处于前台也是如此.当您进入或退出信标区域时,您的应用程序将在后台启动约5秒钟,并会回调didDetermineState: forRegion:方法.

The first time your app runs and sets up a monitoring region, it will be remembered by CoreLocation even after your phone reboots or your app is no longer in the foreground. Your app will then be launched into the background for about 5 seconds when you enter or exit the region of a beacon, and it will get a callback to the didDetermineState: forRegion: method.

您甚至可以在这五秒钟内在后台进行范围调整,此后,iOS将再次暂停您的应用程序.这五秒钟的窗口通常用于向用户发送本地通知,因此,如果需要,他们可以进行手势以将应用程序启动到前台.这样一来,您就可以告诉用户他们在一个兴趣点附近(通过靠近信标触发),然后让他们选择通过点击本地通知来获取更多信息或与应用进行交互.

You can even do ranging in the background for this five second period, after which iOS will suspend your app again. This five second window is typically used to send a local notification to the user, so they can gesture to launch the application into the foreground if desired. This allows you to tell a user they are near a point of interest (triggered by being near the beacon) and then let them elect to get more information or interact with the app by tapping the local notification.

请注意,后台监视回调不是瞬时的.最多可能需要15分钟才能在后台收到通知. 有关详细信息,请参见此处.

Be aware that background monitoring callbacks are not instantaneous. It can take up to 15 minutes to get a notification in the background. See here for details.

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

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