So we are trying to put together a scenario with iBeacons and I think we are getting stuck with the differences between ranging and monitoring in the background and now i'm not sure what we want to do is possible.
We have 500 stores that we want to deploy iBeacons to. The purpose of the beacon is to greet the customer with a notification and a coupon (sometimes). What we would like to do is utilize a single UUID with the major being the store number and the minor being type of store (regular store vs. kids. A kids store can be connected to a regular store). Ideally, once a iBeacon with our UUID is found, we would like our app to pull an XML file from our website specific to the major number (store number), display a notification welcome message (possibly stating 'we have a coupon for you' depending on what the xml file says), and save the xml file data to the app so the user can retrieve the coupon if they open the app. This all seems possible with the application in the foreground, but we seem to be having difficultly getting it to work in the background. Is what I am describing possible and should I be thinking of a different way to do this?
Thanks
Yes, you can do this. The trick is that you need to combine both ranging and monitoring at the same time. Monitoring is needed to launch your app into the background. Ranging is needed to get the specific ids of the Beacons you see.
Set it up like this:
As soon as this happens, you will get ranging callbacks for about five seconds before the application goes back to sleep, and this method will get called once per second:
Two notes of caution:
Monitoring iBeacon Regions in the background can be a little tricky, and it can take longer than you might think to get callbacks. See this detailed discussion.
You only have five seconds from when your app is woken up until it goes back to sleep, so your web site better respond very quickly. A safer idea that would work across network dropouts would be to fetch the XML up front and cache it inside your app so it is ready to go even if there is a network dropout.
My company, Radius Networks makes a library and web service called ProximityKit that does this up-front caching of beacon-specific key/value pairs that you can configure with your web browser. That way, you don't have to write the web service yourself.