I would be really happy if my application could detect beacons in background mode. And not only get notified when they are around but I would like to know when they are in a specific proximity. I know about some possible solutions, but none of them meets all my requirements. I would love if some of Estimote experts in this forum showed me if I get something wrong
SOLUTION 1. Region monitoring.
This is nice, clean and works in background perfectly. However, it doesn’t take proximity into account. If I want to get notified in background that I’m very close to the beacon, I can’t do that, because I get notified about this beacon once I enter its region and it can be far away. And as I get closer and closer, I won’t get any new background notifications.
SOLUTION 2. Region monitoring + setting different power levels for every beacon.
This would solve my problems but in my application it would be extremely cumbersome to set power level for every beacon separately. Thats why I rule out this option.
SOLUTION 3. Ranging
Ranging is proximity-aware. But it doesnt work in background I know I know, battery life.
SOLUTION 4. Ranging + Location enabled
It turns out (I know it from this forum btw, thanks!) that ranging actually does work in background. If we turn on Location updates in CLocationManager, and start ranging, then didRangeBeacons delegate method will be called everytime the didUpdateLocations method gets called. It really worked for me, but there are some drawbacks of this solution:
- Sometimes, when my application goes to background, didUpdateLocation doesn’t get called at all. Therefore, didRangeBeacons is not called too. Do you know why this happens?
- This behaviour is clearly not what Apple intended, so I cannot be sure if this option won’t be removed in the future versions of iOS.
- I haven’t tried to pass this solution through review (mainly beacause of 1. limitation) but I suppose it could be really hard to.
SOLUTION 5. CoreBluetooth Based Scanning: startEstimoteBeaconsDiscoveryForRegion
I was very hopeful about this one. I read that it works in background (we must turn on bluetooth-central background mode ofc) but unfortunately, it didn’t work well for me:
- Most of the time, it worked in background only about 10 seconds and then stopped.
- This method detected 1 out of 3 beacons nearby.
Actually, results of didDiscoverBeacons delegate method were pretty strange and unpredictable, so I assumed I shouldn’t use it too.
None of the solutions is 100% OK. I wonder if there is some other option or maybe I miss something in above mentioned options. I would really love to get it work!
I’m waiting for your insights guys!