13

我在网上看到了新发布的 iOS 7.1 支持 iBeacon 的说法。

具体来说:

  1. 即使用户明确地终止了您的应用程序,系统仍应该通知您的应用程序有关 didEnterRegion/didExitRegion 事件。
  2. didEnterRegion/didExitRegion 通知应该在后台和/或设备锁定时更快。

我无法通过我自己的测试来确认这些说法中的任何一个。事实上,我似乎不太可能从锁定的设备收到 didEnterRegion/didExitRegion 通知。(更准确地说,我似乎收到了 didEnterRegion 通知,但没有收到 didExitRegion 通知)。这可能是因为 Apple 让我删除了 info.plist 中的 BLE 后台模式条目——我不完全确定。我仍在努力解决这个问题。

4

5 回答 5

20

一开始我在设置测试时遇到了麻烦,但我目睹了在 iPhone 4s 和 iPhone 5s 型号的 iOS 7.1 中杀死一个应用程序后后台区域进入回调。有关测试详细信息和重现说明,请参阅下面的评论。

我还在 iPhone 4S 上对背景检测时间进行了测试,但在 iOS 7.1 上我仍然看到 15 分钟的延迟。此处描述了我的完整测试结果和方法。

最后,我还对升级到iOS 7.1前后在同一设备上的“准确度”(距离单位米)测量的波动做了一些测试。我没有看到估计的噪音有明显差异。下图显示了升级前后的结果,iBeacon 在 0.5 米外持续 60 秒,然后移动到 3 米外持续 60 秒。在这两种情况下,发射器都是经过适当校准的带有 iOS 7.1 的 iPhone 4S,而接收器是 iPhone 5S。

iOS 7.0.6

iOS 7.0.6 估计距离

iOS 7.1

iOS 7.1 估计距离

于 2014-03-12T22:21:53.260 回答
1

正如在互联网上流传的几篇文章中所提到的,即使您将应用程序从多任务视图中滑开,也可以使用信标感应。但是在我的实验中,区域进入/退出事件不会直接调用didDetermineState:(可能是因为我没有使用 AppDelegate 来启动任何信标感应,而是基于 UI 事件触发监控)。相反,如果您已注册后台位置更新,则 AppDelegate 的didFinishLaunchingWithOptions : 方法将使用参数 launchOptions 集中的键UIApplicationLaunchOptionsLocationKey的值调用。

您可以像这样进行简单的检查,以测试这是否确实是位置更新,已将您的应用程序购买到后台以执行某些任务。

if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey])

然后,您可以再次注册您的监控区域或立即开始测距。

PS CLLocationManager 会在应用程序恢复时保留您之前监控的区域,但如果不使用相同的 UUID 和身份再次开始监控,您将不会在 CLLocationManagerDelegate 中获得进入/退出区域事件(这使您恢复生机)

于 2014-04-16T09:49:25.280 回答
0

当我的应用程序在 iOS7.1.1 上处于后台模式时,我的测试还重现了 15 分钟开始扫描。有点好奇,我看过很多来自不同公司的 youtube 视频,显示该应用程序在接近信标后立即从后台模式中唤醒。是销售技巧吗?

于 2014-06-10T18:46:33.987 回答
0

在我的测试中,我看到一个应用程序在长达 15 分钟内没有注意到信标的存在,但我发现了一些有趣的东西。我正在使用 RedBearLabs 迷你 BTLE 传感器作为 ibeacon 及其应用程序来对信标进行编程,http ://redbearlab.com/ibeacon/ (http://redbearlab.com/s/MiniBeacon_v1.zip),其中似乎有一个东西可以立即开始扫描/更新信标。如果我启动一个信标,但在我的应用程序中它没有被注意到,通过启动然后退出 MiniBeacon 应用程序,我的应用程序会立即通知我有新的信标。这与进入或退出时的结果相同。他们的应用程序使用 CBCentralManager,而我的应用程序没有,所以也许 CBCentralManager 和 CLBeaconRegion 之间的混合是要走的路?我想 CLBeaconRegion 启动/重新启动蓝牙无线电,所以也许这就是原因。只是尝试一下,希望有更全面了解的人可以帮助解决这个问题。

谢谢

于 2014-03-18T16:31:02.947 回答
0

David has done some wonderful work on this, so I'm writing this cautiously... but I'm seeing something quite different from him in my tests.

I'm using two phones: an iPhone 4S running iOS 7.1 (11D167) and an iPhone 5S running iOS 7.0.6 (11B651). My iBeacons are manufactured and sold by Bluecats (www.bluecats.com), although I'm not yet using their SDK (ie. I'm just using CoreLocation) and I don't think the manufacturer makes much difference.

I'm getting response times of around 1-2 seconds on both devices when the app is running in the foreground and also when running in the background. The only difference is when I remove the app from the app switcher: iOS 7.0.6 never responds (or perhaps will do in 15 minutes), but iOS 7.1 responds in roughly the same time. When I say "respond", I mean that the CLLocationManager's locationManager:didDetermineState:forRegion: delegate is called by iOS.

I'm testing by actually wandering around my office with phones in hand, so I'm physically moving in and out of range. Strangely (?), in my early testing, where I was sitting at my desk and simulating moving in and out of range by removing and reinserting batteries, I was seeing much slower response times. Perhaps this is part of the difference?

于 2014-03-17T23:33:51.630 回答