Requirement
We need to track the user’s location in the background specifically between 9:00 AM and 6:00 PM.
The key requirements are:
What I Have Tried
I initially tried implementing background location tracking using JavaScript with an interval/timer.
However, I observed that the location updates are being received only while the application is actively open/in the foreground. Once the app goes into the background, the JavaScript interval does not reliably continue executing, so location updates stop.
Components / Approaches I Have Tried
I have also explored/tried the following approaches:
The main challenge I am facing is getting reliable location updates while the application is in the background and the device is offline.
Background tracking is the tricky part If you want:
User starts tracking → locks phone → minimizes app → location continues updating
then a normal O11 Mobile screen/client timer isn't enough.
You need native background-location support:
Android
iOS
For a more scalable implementation, consider a WebSocket/push-based approach rather than having every client constantly poll.
The JS interval approach won't work, since the WebView gets suspended in background. Background Geolocation LT (Transistorsoft) already covers what you need natively, you just have to configure it instead of polling from JS:
1) schedule: ['1-7 09:00-18:00'] for the time window
2) Locations are persisted in the plugin's own SQLite while offline
3) url + autoSync: true posts them to your REST endpoint when connectivity is back (batchSync if you want them in bulk)
Config reference: https://transistorsoft.github.io/cordova-background-geolocation-lt/interfaces/config.html
One gotcha: on Android it works in debug builds, but release builds need a paid license key. That's often why it "stops working" after going to production. On iOS remember to enable Background Modes > Location updates.