Reputation: 6332
Disclaimer - I'm a server side engineer so my knowledge here is limited.
Question - if my ios app is in the background, will region monitoring allow multiple events after the initial region has been entered?
Use case - with the app in the background, a user enters a facility with multiple beacons deployed. I'd like the app to periodically make service calls while they are in the region, one call as they get closer to one of the beacons. ie "I'm close to beacon 1 now" then later "I'm close to beacon 2 now". Is that feasible?
Note - I do not need to triangulate the user.
Upvotes: 0
Views: 334
Reputation: 64941
Yes, it is possible to make service calls when an app is in the background based on changing distance to beacons. Getting regular distance updates to beacons is called "ranging" and it works on both iOS and Android platforms. But there are some serious restrictions on iOS.
Android - Background ranging is straightforward on the Android platform. Using the Android Beacon Library, you can continue ranging beacons in the background and make service calls when the estimated distance changes. The library allows a configurable interval of how often beacons are ranged in the background (every 5 minutes by default to save battery). But this can be increased to any interval you want.
iOS - Background ranging is severely limited by the iOS to save battery. By default, you can only range for beacons for 10 seconds in the background. This 10 second timer starts when your app moves from the foreground to the background. The app can also temporarily wake up into the background when a new beacon region is detected using the monitoring APIs. This starts the 10 second timer anew.
After the 10 seconds expires, the app is suspended on iOS, which means that ranging stops and any service calls do not complete. The good news is that you can extend this background execution time from 10 seconds to 180 seconds by making a special request to the operating system. That request is described in the link below.
When 180 seconds is not enough, you can get more time by designing your beacon identifiers to give you multiple background triggers with the monitoring APIs. As you move around the space, you can get a new background monitoring trigger (which restarts the clock on background ranging) by detecting a beacon with a different ProximityUUID/major combination. To do this, you must place these beacons with these different identifier combinations in non-overlapping radio range, so you get new entry/exit monitoring triggers as you move around the space. You must also register these different beacon regions for monitoring with the operating system so you get the background triggers.
You can read more about these techniques here: http://developer.radiusnetworks.com/2014/11/13/extending-background-ranging-on-ios.html
Upvotes: 2