信标和本地通知 [英] iBeacons and local notifications

查看:88
本文介绍了信标和本地通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开发了一个基于iBeacon的小型应用程序,当该应用程序检测到我们的iBeacon之一调用了Web服务以获取数据集并将本地通知发送给用户时.所有这一切都正常工作.

I have developed a small iBeacon based application, when the application detects one of our iBeacons makes a call to a web service to obtain a data set and send a local notification to the user. All this is working correctly.

我现在提出了这样的想法,即这些本地通知可能会在很短的时间间隔内随着新内容而变化.问题在于,如果用户不离开iBeacon区域并重新进入,则应用程序将不会唤醒",并且用户将不会收到新的更新通知.

I have now raised the idea that these local notifications could vary over short time intervals, with new content. The problem is that if the user does not leave the region of the iBeacon and reenters, the application will not "wake up" and the user will not receive the new updated notification.

我不知道这是否可以通过某种方式解决,或者实际上做类似这样的事情的方法不应该与iBeacons的技术有关.

I do not know if this could be solved somehow or actually the approach to make something like that should not be related to technology of iBeacons.

我真的迷路了,不知道是否有人会建议我如何提高它.

I'm really lost and do not know if anyone would know advise me on how to raise it.

推荐答案

为此,您需要使应用程序在信标附近时在后台运行.允许您定期检查与信标关联的更新内容,然后在两种情况下显示通知:

In order to do this, you need to get the app to run in the background while beacons are in the vicinity. This would allow you to periodically check for updated content associated with the beacon and then display notifications under two conditions:

  1. 当信标第一次出现时,并且有与该信标关联的消息.
  2. 与上述信标相关的消息在信标仍然可见的时间内发生变化.

正如您提到的,第二项是一个问题,因为尽管 iOS会在信标的5秒钟之内将iOS暂停应用,但您仍需要一种方法来连续检查是否有更新的内容在后台进行检测.

As you mention, the second item is a problem, because you need a way to continually check to see if there is updated content despite the fact that iOS will suspend your app within 5 seconds of beacon detection in the background.

一些选项,每个选项都有缺点:

A few options, each of which have downsides:

  1. 您可以使用自定义硬件信标,该信标每分钟左右更改一次其标识符(例如,未成年人在0到1之间来回移动).这样一来,您可以监视两个区域,并在信标附近每隔一分钟重新触发一次.缺点:这需要建立一个自定义信标.

  1. You can use a custom hardware beacon that changes its identifier every minutes or so (e.g. the minor goes back and forth between 0 and 1). This would allow you to monitor two regions and re-trigger on each every minute the beacon is in the vicinity. Downside: This requires building a custom beacon.

您可以让您的应用请求额外的3分钟后台运行时间,在此期间您可以检查更改的消息.缺点:您只有三分钟的时间来显示已更改的消息.

You can make your app request an extra 3 minutes of background running time during which you can check for changed messages. Downside: You only get three minutes to display changed messages.

您可以在.plist中指定其他后台模式,以便您可以继续在后台运行.缺点:除非您有充分的理由在后台运行(例如导航应用程序或音乐播放器应用程序),否则苹果不会批准您的应用程序在商店中分发.

You can specify extra background modes in your .plist so you can continue running in the background. Downside: Apple won't approve your app for distribution in the store unless you have a good reason to run in the background (e.g. a navigation app or a music player app.)

每次消息更改时,您都可以向应用程序发送推送通知,这将在后台唤醒您的应用程序,因此,如果附近有信标,则可以显示更新的通知.缺点:设置推送通知有点复杂,交付速度可能很慢,而且不能保证.

You can send a push notification to your app each time the message changes, which would wake up your app in the background so you could display an updated notification if a beacon is in the vicinity. Downside: Setting up push notifications are a bit complex, delivery can be slow, and is not guaranteed.

在此处阅读有关这些选项的更多信息:

Read here for more info on some of these options: http://developer.radiusnetworks.com/2014/11/13/extending-background-ranging-on-ios.html

这篇关于信标和本地通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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