iBeacon是如何唤醒我们的应用程序的?多长时间?以及如何延长时间? [英] How does iBeacon wake up our app? For how long? And how to extend that time?

查看:352
本文介绍了iBeacon是如何唤醒我们的应用程序的?多长时间?以及如何延长时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

经过对iBeacon的一些研究后,我提出了以下问题,我找不到扩展帮助:


  1. iBeacon会唤醒我们的应用程序吗?如果应用程序被暂停,它是否会将我们的应用程序置于后台模式以唤醒我们的应用程序?


  2. iBeacon将我们的应用程序置于什么背景模式?我们在这种后台模式下可以做些什么?


  3. 此背景模式在再次暂停之​​前可以持续多长时间?当它即将被暂停时,调用了什么函数?


  4. 如果需要,我们如何延长这个背景时间?


  5. 众所周知,iBeacon只会在区域更改(进入/退出)时唤醒我们的应用程序,但如果用户仍在同一区域,我们如何重新启动用户的应用程序?


提前谢谢。

解决方案

一些答案​​:


  1. iBeacon可以使用监控API将您的应用程序唤醒到后台。它可以做到这一点,即使您的应用程序自设备重启后尚未启动,或者即使应用程序已从任务切换器中被杀死(虽然后者需要iOS 7.1+)这可以通过您的应用程序调用 startRangingBeaconsInRegion: CLLocationManager 上的方法,还实现了 CLLocationManagerDelegate 协议的 locationManager:didDetermineState:forRegion: locationManager:didEnterRegion:和/或 locationManager:didExitRegion:方法。


  2. 即使您的应用未运行,您的应用也会启动到后台,并且在检测到与传递的区域定义匹配的信标时调用上述方法。您可以在此时执行任何不需要用户界面的代码。通常,这包括更新应用程序状态,调用Web服务或发送本地通知以鼓励用户将应用程序带到前台。 (不,你不能以编程方式将你的应用程序带到前台。)


  3. 该应用程序只能在后台运行大约五到十秒再次暂停。 (如果你的应用程序已经在前台,它将无限期地继续运行。)如果它在这短暂的时间后被暂停,你的类实现了 UIApplicationDelegate 协议 applicationWillResignActive:方法被调用。


  4. 您可以通过调用 beginBackgroundTaskWithExpirationHandler来请求额外的后台时间: UIApplication 类的方法。但是不能保证这个额外的时间,并且你不能无限期地继续这样做。


  5. 一旦你的应用程序进入某个地区并且你收到了一个背景通知,在退出之前,无法再获取第二个通知来唤醒同一地区的应用。您可以通过定义多个区域并拥有可能触发更多条目和退出的多个信标来进行游戏。但这些都是变通方法。一般情况下,如果没有额外的进入/退出事件,您无法使用此技术重新启动应用。



after some research of iBeacon I came up with the following questions that I couldn't find extended help:

  1. How does iBeacon wake up our app? Does it wake up our app by putting our app into background mode if the app was suspended?

  2. What background mode did iBeacon put our app into? What can we do in this background mode?

  3. How long can this background mode last before it is suspended again? When it is about to be suspended, what function was invoked?

  4. How can we extend this background time if we need to?

  5. As we all know iBeacon only wakes up our app when region changes (enter/exit), but how do we relaunch user's app if user is still in the same region?

Thank you in advance.

解决方案

Some answers:

  1. An iBeacon can wake up your app into the background using monitoring APIs. It can do this even if your app has not been launched since device reboot, or even if the app has been killed from the task switcher (although the latter requires iOS 7.1+) This works by your app calling the startRangingBeaconsInRegion: method on CLLocationManager, and also implementing the CLLocationManagerDelegate protocol's locationManager:didDetermineState:forRegion:, locationManager:didEnterRegion: and/or locationManager:didExitRegion: methods.

  2. Even if your app is not running, your app will get launched into the background and the above methods called when a beacon matching the passed region definition is detected. You can execute any code you want in this time that doesn't require a user interface. Typically, this includes updating application state, calling a web service, or sending a local notification to encourage the user to bring the app to the foreground. (And no, you cannot programmatically bring your app to the foreground.)

  3. The app only gets to run for about five to ten seconds in the background before being suspended again. (If your app were already in the foreground, it would get to continue running indefinitely.) If it is suspended after this brief time your class implementing the UIApplicationDelegate protocol applicationWillResignActive: method gets called.

  4. You can request additional background time by calling the beginBackgroundTaskWithExpirationHandler: method of the UIApplication class. But getting this extra time is not guaranteed, and you cannot continue to do this indefinitely.

  5. Once your app enters a region and you get a background notification, you cannot get a second notification to wake up your app for the same region until you exit it. You can game this a bit by defining multiple regions and having multiple beacons that might trigger more entries and exits. But these are all workarounds. In general you cannot relaunch the app with this technique if there is no additional entry/exit event.

这篇关于iBeacon是如何唤醒我们的应用程序的?多长时间?以及如何延长时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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