1

I'm working on a project with iBeacon that requires the app run constantly in the background. Nevermind the practicality of this, please. The iBeacon API doesn't allow apps to range in the background constantly or receive any other communication other than enter/exit events (accept in the case where you set the needsDisplay flag, but this isn't as passive as I need it to be). Once in a particular region, it seems you can't detect which beacon you're closest to while the app is completely backgrounded.

In order to hack this into working, I set up a couple of iOS devices as CoreBluetooth peripherals, plugged in and always on that the app can constantly "discover." Because the BLE profile used for the peripherals are "connectable," the app can stay on infinitely in the background and iBeacon ranging is possible all throughout the day. To boot, I've seen very minimal battery life reduction.

The problem now, is that every other day or so, the app quits and is not awakened by the enter/exit events, nor is it awakened by the other BLE devices when in range.

I understand that with a hacky solution like this, there are bound to be a myriad of problems, but for the life of me I can't narrow down what might be causing this. Thoughts?

d2burke
  • 4,081
  • 3
  • 39
  • 51

1 Answers1

2

Every once in awhile, CoreLocation will get hung up and not report any new entry/exit events. Rebooting the phone generally fixes this. An increase in anecdotal reports suggest this may be more common since the release of iOS 7.1 (I have seen two other questions like this in the past few weeks on StackOverflow, and we have gotten lots of support requests on this issue at Radius Networks), but there is no hard evidence to prove a change in 7.1 affects this.

EDIT: Additional data gathered elsewhere shows that when these hang-ups happen, Bluetooth continues to function normally and it is still possible for the hung-up device to transmit as an iBeacon. This suggests a bug in CoreLocation that causes periodic Bluetooth LE scans to look for iBeacons to stop. So far the only known fix is to reboot the affected phone.

The problem is rare enough that I have never been able to characterize it to know the root cause. Is it a Bluetooth problem? A CoreLocation problem? Your setup might be producing an ideal means of finding the issue.

As soon as you reproduce this issue, here is what I would do:

  1. Start another iBeacon scanning program like Locate for iBeacon, and have it range for any iBeacons in the area (be sure your Proximity UUIDs are configured.) Do you see them? If so, Bluetooth and CoreLocation work, so the issue may be with your app.

  2. If you do not see any iBeacons in (1), go to Settings > Bluetooth, and do a scan for other nearby devices (even classic Bluetooth devices). Make your Macbook or bluetooth headset visible to make this easy to test. If you do not see any devices then bluetooth is hung up. Try turning it off and back on.

  3. If you see Bluetooth devices in (2) but no iBeacons in (1) then there may be an OS problem with handling CoreLocation.

I'd be interested in knowing what you see. The procedure above won't fix your problem, but it might give some more evidence of what is going on that will make a fix possible.

Here are other questions where users report a similar problem:

iOS app with iBeacon must restart device

ibeacon does not apear in iPhone 4S

Community
  • 1
  • 1
davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • thanks @davidgyoung. I'll take those steps and see where it goes. I really appreciate the info. – d2burke Apr 07 '14 at 18:22