简体   繁体   English

不运行且iBeacon在范围内时调用应用程序

[英]invoking application when not running and iBeacon in range

I am working on an iPhone app that notifies a user when he enters in the region of an iBeacon. 我正在开发一个iPhone应用程序,当用户进入iBeacon区域时会通知用户。

I have a few question regarding the same: 我对此有几个问题:

From documents: 来自文件:

Monitoring launches app when entered in the region of iBeacon being monitored. 在被监视的iBeacon区域中输入时,监视启动应用程序。

But the behavior is: 但是行为是:

It only works when phone is awakened ie When display is turned on. 它仅在手机唤醒时(即显示屏打开时)起作用。 But when app is not running and display is off nothing happens same is the case when display is on and user enters in the region of the beacon. 但是,当应用程序未运行且显示关闭时,显示打开且用户进入信标区域时,不会发生任何事情。

Is it possible to launch application when users enter/exits the region even when display is off or on not just when phone is awakened? 当用户进入/退出该区域时,即使显示器处于关闭状态还是仅在唤醒手机时仍可以启动应用程序?

I checked this iBeacon Notification when the app is not running link, which shows it is possible. 当应用未运行时,我检查了此iBeacon通知链接,这表明可能。 I am monitoring an iBeacon but not able to get the expected behavior. 我正在监视iBeacon,但无法获得预期的行为。 Am I missing something?? 我错过了什么吗?

Any help is appreciated. 任何帮助表示赞赏。

Yes, you can get notified on entering a region in the background. 是的,您可以在后台输入区域时得到通知。 This will happen as long as: 只要发生以下情况,就会发生这种情况:

  • The app has been opened at least once 该应用已至少打开一次
  • The user did not kill the app directly (by quitting the process, not just dismissing it) 用户没有直接终止该应用程序(通过退出该过程,而不仅仅是将其关闭)

Now understanding how it behaves aa little more nuanced. 现在了解它的行为有点细微差别。

At my company we've done a fair amount of research on this. 在我公司,我们已经对此进行了大量研究。 In fact a colleague of mine wrote a great blog post about the behavior: iBeacon Monitoring in the Background and Foreground . 实际上,我的一位同事写了一篇有关该行为的出色博客文章:“ iBeacon Monitoring in the Background and Foreground”

What was unexpected was how long it can take to get a didEnterRegion in the background: 出乎意料的是,要在后台获得didEnterRegion需要多长时间:

Condition                                      Max time to detect a region change
--------------------------------------------   ----------------------------------
Phone awakened,notifyEntryStateOnDisplay=YES   1 second
Phone awakened, notifyEntryStateOnDisplay=NO   NEVER
UIBackgroundModes=location ON                  up to 15 minutes
UIBackgroundModes=location OFF                 up to 15 minutes

There are a couple of properties you can set on a CLBeaconRegion to alter when your app will be notified about a change to the user's location in relation to that region: 您可以在CLBeaconRegion上设置几个属性,以在通知您的应用有关该用户相对于该区域的位置更改时通知您的应用:

  • notifyOnEntry - you will be notified via locationManager:didEnterRegion: when the user enters the region notifyOnEntry当用户进入区域时,将通过locationManager:didEnterRegion:通知您
  • notifyOnExit - you will be notified via locationManager:didExitRegion: when the user exits the region notifyOnExit当用户退出区域时,将通过locationManager:didExitRegion:通知您
  • notifyEntryStateOnDisplay - you will be notified via locationManager:didDetermineState:forRegion: when the user wakes their device's screen up and they are inside the region notifyEntryStateOnDisplay当用户唤醒其设备的屏幕并且位于区域内时,将通过locationManager:didDetermineState:forRegion:通知您

Note that you must completely exit a region before didEnterRegion: is called again, and sometimes it can take a minute or more for the device to properly register that you have left a region. 请注意,您必须在再次调用didEnterRegion:之前完全退出区域,有时设备可能需要一分钟或更长时间才能正确注册您已离开区域。 Because a beacon can broadcast up to 30 or 50 meters (or perhaps more), you either have to move a long way away from a beacon to leave a region or otherwise turn the beacons off , wait for a minute or so, and then back on to trigger a change. 由于信标可以广播长达30或50米(或更长),因此您要么必须离开信标很远才能离开某个区域,要么要关闭信标,等待一分钟左右,然后再返回触发更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM