1

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.
7
  • When dealing with beacons, you don't have to do anything with startUpdatingLocations. If I were you, I would configure the beacon range on the beacon itself so that the radius of the region is the size of the room, and when you monitor for the beacon region you will get didEnterRegion callback in the background and will be able to trigger what you want basically immediately. Commented Aug 25, 2014 at 23:43
  • That is what I did, but am not getting the callbacks immediately. According to Dave, this may be expected, unfortunately. Commented Aug 26, 2014 at 1:28
  • I'm sure every beacon/device is different, but in my experience it happens within a second or two. Just my 2 cents, your mileage may vary. Commented Aug 26, 2014 at 1:29
  • Interesting. Would you be able to post a code sample? Commented Aug 26, 2014 at 1:38
  • CLBeaconRegion *beaconRegion = [[CLBeaconRegion alloc] @"beacon's UUID" @"some identifier"]; [_locationManager startMonitoringForRegion:beaconRegion]; Commented Aug 26, 2014 at 1:40

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

I have not done such testing yet. If you look at the first link in my answer above, there is a project on GitHub and instructions you can use to reproduce my tests, if you would like to do so on iOS8. Please post your results if you do!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.