Search code examples
iosobjective-ccllocationmanageribeacon

How to get background updates for iBeacons without using locationManager didEnterRegion


I'd like to get background updates to my app for beacon proximity (entering a region) but I've just read on the Apple docs that:

When testing your region monitoring code in iOS Simulator or on a device, realize that region events may not happen immediately after a region boundary is crossed. To prevent spurious notifications, iOS doesn’t deliver region notifications until certain threshold conditions are met. Specifically, the user’s location must cross the region boundary, move away from the boundary by a minimum distance, and remain at that minimum distance for at least 20 seconds before the notifications are reported.

Ideally I'd like to use a different API - one that tells me as soon as the beacon is detected (and conversely undetected), without applying Apple's heuristic.

I could have ranging turned on for all possible beacons all the time, but that'd kill the battery pretty fast I imagine.

Surely there's a way to do this, otherwise I sort of see the promise of iBeacon broken :/


Solution

  • Those docs are misleading because they are meant to cover monitoring for geofence regions (e.g. CLCircularRegion) as well as beacon regions (CLBeaconRegion). The Heuristics you describe apply only to geofences.

    For beacons, detection times on entering a region vary depending on the hardware. On iPhone 4S devices, beacon region entry events take up to 15 minutes (beacon scanning is every 15 minutes.) On iPhone 5+ devices, detection is usually within one second thanks to hardware assist, but if all assist slots have been taken (30 region max), it falls back to the behavior similar to an iPhone 4S.

    It should also be noted that if ranging is active, detection times are within one second.

    Read more detail here:

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

    http://developer.radiusnetworks.com/2015/04/21/max-beacon-regions-ios.html