Hi everyone,
I'm building an trekking app using Cordova plugins and Mapbox. The logic tracks paths and writes to local storage perfectly in the foreground, but the tracking drops intermittently when the app is backgrounded. We've identified that the Background Mode plugin is killing the Location plugin when the app goes into the background.
Which background geolocation plugin works most reliably with OS11 mobile lifecycles without getting suspended?
Are there any hidden caveats when writing to local storage directly from a background tracking callback event?
Any advice or patterns would be a huge help!
Thanks,
Pramodh
For reliable background tracking in a Cordova trekking app, you should use Transistorsoft’s cordova-background-geolocation plugin, because it is designed to keep GPS tracking active even when the app is in background or terminated, unlike the basic Background Mode plugin which often fails on iOS/Android lifecycle limits. The main issue in your setup is writing directly to localStorage inside background location callbacks, which is unsafe because the OS can suspend the JavaScript thread anytime, leading to missed updates or data loss. Instead, you should store incoming location points in an in-memory queue and periodically flush them in batches, or use a more reliable storage option like IndexedDB or NativeStorage. This approach ensures smoother tracking, prevents blocking, and handles OS-level suspensions more safely.
Hi Lokesh,
Thanks for the insight! That explains exactly why we are losing data—the JavaScript thread suspending mid-write makes perfect sense. Since OutSystems 11 uses local SQLite entities under the hood for mobile, do you recommend batching the points in an in-memory array before saving them to the local entity, or should we completely bypass local entities and use a NativeStorage plugin for background callbacks instead?