I have a requirement for my app to sense that i'm in a beacon region for last n minutes, and then based on such static presence do some action. It works very well baed on Ranging calls now, by me checking for the last n ranging regions to be the same. But this does not work when app is in background since only enter/exit regions are invoked and not Ranging delegates.
One way I am thinking of implementing it is:
1. When EnterRegion is called, ask iOS for more time to execute - if in background mode.
2. Initiate a scheduled timer task to connect to the beacon 2 mins later, and get some property.
3. If this succeeds, it proves that beacons is still in proximity and hence deduce that i've been static in its proximity.
1. You enter the region, iOS wakes the up and delivers the didEnterRegion event. Your app send this information together with a timestamp to an external server.
2a. On the server, you monitor the dwell time and if it reaches certain amount, you send a push notification to the application. Push notification wakes the up, and you can perform the action you have in mind.
2b. If before reaching the dwell time threshold you leave the beacon region, didExitRegion gets called and you can notify the server that the device is no longer in range of the beacon. This stops the dwell time monitoring.
This way, there's no need to keep the app continuously running in the background—preserving the battery life, and also not having to worry about the 3 minute limit for background tasks that iOS 8 imposes.