I'm building a location-aware app in Phonegap that has to check location periodically in the background to determine when user enters/exits specific places. This question is about iOS specifically. The Significant-change API is no good for me because it's accuracy level is like more street-wise then building-wise, and the latter is what the app requires.
So far, after reading the comments in the great answer to this, I've managed to keep the app alive in background with a combination of this background mode declaration (in config.xml):
<gap:config-file platform="ios" parent="UIBackgroundModes" mode="replace">
<array>
<string>location</string>
</array>
</gap:config-file>
and once when the app is in foreground after it was launched, calling:
navigator.geolocation.watchPosition(...)
I figured what I would like is perhaps what they talk about in here (but that is native and regardless to Phonegap...).
What whould be the best strategy to achieve this in the Phonegap way?
Do you guys know a plugin or a combination of plugins to make it possible?
Should I abuse timed remote notifications to make the app wake up (heard it may be possible, don't know how apple will approve that...)
Or must I make my own plugin for this purpose?
Any advice or experience will be appreciated.
As for what I got to learn through the months passed after asking that Q, it's impossible to wake an app in background on a timed interval in iOS.
As I stated in the Q, my objective was to determine when user enters/exists specific places (buildings, actually). The best way possible to address this is the Region Monitoring API in iOS which wakes up the app in background once the device enters specific geographical regions predetermined by the app. It has some limitations though but we are trying various optimizations to somewhat overcome them.
A few plugins for cordova exists, this is the one I chose eventually: https://github.com/cowbell/cordova-plugin-geofence
Took some time to implement...