Search code examples
ioscore-locationibeacon

iBeacon detection time in background (Home automation use case)


I know this has been asked in many varieties but I have yet to see a full answer for this. I just get a lot of conflicting information.

I'm trying to use iBeacon for a home automation use case. For example, if I walk into a room with an iBeacon I turn on the lights in that room. As you can imagine, I need this to be pretty prompt (within a couple of seconds of walking in the room). When I have my app in the foreground, this works great - the timing is prompt for both entering and exiting the region. However, if the app is in the background it's more unreliable. If I call [self.locationManager startUpdatingLocation] and never stop updating location, the iBeacon detection works the same as if the app is in the foreground. However, I assume this is not the intended use case as that will probably drain your battery after a while. My questions are:

  1. What is the expected time for monitoring iBeacons (just getting entry / exit callbacks) in the background vs the foreground?
  2. Is there a way to have iBeacons in the background work as quickly as the foreground without calling [self.locationManager startUpdatingLocation]? Once the location arrow turns from active location monitoring to the arrow with the geofence outline, I immediately stop getting iBeacon notifications.

Solution

  • Unfortunately, you cannot count on fast detection times in the background on iOS. Timing depends on device and device state, and detections can take up to 15 minutes. You might get faster detections in some cases, but you simply cannot count on it.

    See:

    http://developer.radiusnetworks.com/2014/03/12/ios7-1-background-detection-times.html

    And:

    http://developer.radiusnetworks.com/2013/11/13/ibeacon-monitoring-in-the-background-and-foreground.html

    Sorry, I know this is not the answer you want to hear. Unfortunately, this use case can only work with an app in the foreground on iOS.