13

I've seen claims on the net that the newly released iOS 7.1's iBeacon support.

Specifically:

  1. The system is supposed to still notify your app about didEnterRegion/didExitRegion events, even if the user explicitly kills your app.
  2. didEnterRegion/didExitRegion notifications are supposed to be faster from the background and/or with the device locked.

I have not been able to confirm either of these claims with my own testing. In fact, I seem to be less likely to get didEnterRegion/didExitRegion notifications from a locked device. (more accurately I seem to get didEnterRegion notices, but not didExitRegion notices). That could be because Apple made me remove my BLE background mode entries in my info.plist - I'm not completely sure. I'm still trying to sort this out.

Duncan C
  • 128,072
  • 22
  • 173
  • 272

5 Answers5

20

I had trouble setting up my tests at first, but I have witnessed background region entry callbacks after killing an app in iOS 7.1 on both iPhone 4s and iPhone 5s models. See comments below for testing details and instructions to reproduce.

I have also done tests on background detection times on an iPhone 4S, and I still see delays of 15 minutes on iOS 7.1. My full test results and methodology are described here.

Finally, I have also done some tests on the fluctuations on the "accuracy" (distance in meters) measurement on the same device before and after the upgrade to iOS 7.1. I do not see an obvious difference in the noise on the estimate. The graphs below show results before and after the upgrade, with an iBeacon 0.5 meters away for 60 seconds then moved to 3 meters away for 60 seconds. In both cases, the transmitter was a properly calibrated iPhone 4S w/ iOS 7.1 and the receiver was an iPhone 5S.

iOS 7.0.6

iOS 7.0.6 Estimated distance

iOS 7.1

iOS 7.1 Estimated distance

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • Thanks for weighing in David. I was hoping to hear from you. (voted.) I'm not going to accept an answer for a while because I want to hear from as many people as possible, but your answer is through as always. – Duncan C Mar 12 '14 at 23:19
  • P.S. I see you're in the DC area. Whereabouts? I'm in Great Falls/Sterling. – Duncan C Mar 12 '14 at 23:20
  • Our Radius Networks office is in Georgetown, DC. Perhaps we will meet in the physical world before long. – davidgyoung Mar 12 '14 at 23:59
  • Indeed. Do you ever go to the MoDev brown bag lunch meetings? There was one on BLE several months ago that I attended. – Duncan C Mar 13 '14 at 00:10
  • I just edited my answer to confirm I *AM* getting region entry callbacks after killing an app. – davidgyoung Mar 14 '14 at 14:27
  • What background modes do you have to specify in your info.plist in order to get iBeacon notifications in the background? I used to have the bluetooth-central Background mode set in our beacon developer's app, but Apple rejected an update to the app with that flag in place. I've since removed it, and now I don't appear to be getting beacon notifications in the background any more. Do you need either bluetooth-central or location background mode values in order to get beacon notifications in the background? – Duncan C Mar 14 '14 at 15:21
  • I do not have any background modes listed at all. I tested this with our open source Beacon Scavenger Hunt app available in the AppStore and on github here: https://github.com/RadiusNetworks/scavenger-hunt-ios-os. Try it yourself and check out the source code. – davidgyoung Mar 14 '14 at 19:20
  • To test, simply start a scavenger hunt with code 00000000, turn on an iBeacon with 2F234454-CF6D-4A0F-ADF2-F4911BA9FFA6 1 1, earn a badge, then turn off Bluetooth, kill the app, turn on Bluetooth, and wait 15 min for a guaranteed notification. – davidgyoung Mar 14 '14 at 19:44
  • David, I see quite many youtube video that when a user passing by a beacon with iphone and the app is in background mode, a notification is poped up immediately. As your testing shows there is a 15 mins delay, are you saying those video are some sales trick? – Hammer Jun 10 '14 at 15:38
  • I'm not saying that. I do not dispute that under certain conditions with certain devices detections can happen within a few seconds in the background. But I know this does not **always** happen on all devices in all states. For the sake of developers' sanity, I think it is important to set expectations based on the worst case scenario, not ideal conditions, otherwise folks testing our apps will tell us they are broken. Unfortunately, Apple is opaque about exactly what conditions are required for ideal performance. – davidgyoung Jun 10 '14 at 17:46
1

As has been mentioned in several articles circulating around the internet, beacon sensing is available even when you swipe your app away from the multi-tasking view. However in my experiments, a region enter/exit event doesn't call the didDetermineState: directly (Probably because I hadn't been using the AppDelegate to initiate any beacon sensing but instead triggering monitoring based on UI events). Instead if you have registered for Background Location Updates, your AppDelegate's didFinishLaunchingWithOptions: method would get called with the value for key UIApplicationLaunchOptionsLocationKey in the parameter launchOptions set.

You can do a simple check like this to test if this is indeed a location update that has bought your app into the background to perform some task.

if ([launchOptions objectForKey:UIApplicationLaunchOptionsLocationKey])

You can then either register your monitored regions again or start ranging immediately.

P.S. CLLocationManager retains your previously monitoredRegions on app restore but without starting monitoring again using the same UUID and identity, you would not get the enter/exit region event in CLLocationManagerDelegate (which had brought your back up to life)

kodr
  • 51
  • 1
  • 4
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?

mblackwell8
  • 3,065
  • 3
  • 21
  • 23
  • Just to be sure, "but iOS 7.1 responds in roughly the same time" does that mean that iOS 7.1 responds after 1-2 seconds when the app is terminated from the app switcher? – Segev Mar 25 '14 at 15:53
0

In my testing I have seen the presence of a beacon go un-noticed by an app for up to 15 minutes, but I found something that's interesting. I'm using RedBearLabs mini BTLE sensors as ibeacons and their app to program the beacons, http://redbearlab.com/ibeacon/ (http://redbearlab.com/s/MiniBeacon_v1.zip), seems to have an something in it that immediately starts a scan / update of beacons. If I start a beacon up, and in my app it goes unnoticed, by starting then quitting the MiniBeacon app my app immediately notifies me that there are new beacons. This is the same result when entering or exiting. Their app uses CBCentralManager, which my app doesn't, so maybe a mixture between CBCentralManager and CLBeaconRegion is the way to go? I imagine CLBeaconRegion starts / restarts the bluetooth radio, so maybe that is the reason for this. Just taking a stab at it in hopes that someone with a more complete understanding can help resolve this.

Thanks

user2812463
  • 265
  • 5
  • 14
  • I have seen this, too. Two apps on the same device *absolutely can* affect each other by making a BLE scan, either through CoreBluetooth directly or by ranging for iBeacons. If one app does a BLE scan in the foreground, the BLE scan results will immediately trigger iBeacon detections for any apps in the background. I suspect this is what you are seeing with the MiniBeacon app. Unfortunately, this is not useful for speeding up background detection because you have no control over the scanning behavior of external apps. – davidgyoung Mar 20 '14 at 03:48
0

My testing also reproduces 15 mins to start scanning when my app is in background mode on iOS7.1.1. Just a bit curious, I have seen quite many youtube videos from different companies showing the app has been waken from background mode as soon as they approach their beacons. Is it sales trick?

Hammer
  • 8,538
  • 12
  • 44
  • 75
  • I get very mixed results. Sometimes my app wakes up and gets notified immediately. More often it takes a couple of minutes. I've only seen a full 15 minute delay a few times. I think that's a "worst case" response time. – Duncan C Jun 10 '14 at 18:53
  • Let me share more abt our testing.1) In foreground, like others suggested, almost instantly; 2) when app is not in foreground,but another app is, around 15 mins to respond, 3) phone awaken while locked, result seems inconsistent, which varies from 1-2 seconds to 7-8 seconds 4) phone not awaken, results are also inconsistent, varies from 4-5 seconds to 10+, much slower than 3). – Hammer Jun 12 '14 at 14:04