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(...)
What I need is:
- The app to be fully suspended between intervals (as it will kill the battery to have the app alive in BG under watchPosition all day long), and woken up just to perform a single getcurrentPosition + POST to a server each time.
- The app to be launched into that routine right from device boot.
So:
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.