3
votes

For a specific business case, I would like to trigger proximity-based notification (push or UILocalNotification) by leveraging the iBeacon technology. This is aimed to work while the app is in background/lockscreen.

I have some specific constraints :

  • The product has to scale at a certain level so it's not possible to range 20 regions. We will range on one UUID only (maybe 2 or 3 if we develop new set of features, but we will not register a region per physical beacon)

  • We will use the major and minor to call webservices

  • Regarding this, I know I will have to use the following approach : first didEnterRegion: with no prior information on the major/minor/distance, and then didRangeBeacon: to perform more advanced actions. I already use local storage mechanisms to timeout a beacon after he has been used considering the fast beaming rate of beacons.

    * The major constraints : we have to region events regarding to the distance of the beacon (exemple, only trigger the notification if CLProximityImmediate)

Now I see a major limitation. As my app will only range in background for a few seconds after it entered in a region, if I had constraints based on the distance/proximity, it is very possible that the app will:

  • return to background state before the user get close enough from the physical beacon for the event to be triggered
  • never be triggered again because it has to enter the region to range again, which will probably not happen

Do you have any ideas / work around for such a case ?

1

1 Answers

3
votes

You are absolutely correct on the limitations CoreLocation applies in this use case. If you set it up as you describe, the typical behavior will be that the app will detect the beacon in the background at an unknown distance (often the max range of around 50 meters), range in the background for about 5 secs, then the app will be suspended by iOS. That five seconds of ranging time will typically not be enough for the user to get near enough to the beacon to trigger your use case.

Unfortunately, there are no easy workarounds with standard beacons and CoreLocation. CLBeaconRegion objects do not have a distance field like CLCircularRegion does for geofences.

Two more extreme approaches you might try:

  1. Turn off monitoring of your one region as soon as you detect the device is too far away, then re-enable it right as your app suspends itself in the applicationWillResignActive: callback. You might get a new entry event and more background ranging time.

  2. Use nonstandard beacons that periodically stop their transmissions to trigger forced exit/entry events.