How is your experience with the OutSystems Community?
15
Views
2
Comments
background location tracking

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:

  • Location tracking should continue even when the application is running in the background.
  • It should not stop when the app is minimized or the user switches to another application.
  • The location tracking should work offline, without requiring a continuous internet connection.
  • Location data collected while offline should ideally be stored locally and synchronized with the server once the internet connection becomes available.
  • Tracking should operate only during the required time window, i.e. 9:00 AM to 6:00 PM.
  • We need a reliable approach that works consistently on both Android and iOS, subject to their background execution and location restrictions.
  • Battery consumption should also be considered, since continuous GPS tracking can have a significant impact.

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:

  • Background Location plugin
  • Significant Location Change
  • GPS tracking
  • Background Geolocation Services
  • Background Geolocation LT
  • JavaScript setInterval() based location tracking

The main challenge I am facing is getting reliable location updates while the application is in the background and the device is offline.

2026-02-26 06-29-24
Rahul
 
MVP

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

  • Background/foreground location service
  • Appropriate location permissions
  • Battery optimization considerations

iOS

  • Background Location capability
  • Appropriate location permissions
  • Significant battery considerations

For a more scalable implementation, consider a WebSocket/push-based approach rather than having every client constantly poll. 

2026-09-26 04-01-21
Huarlem Lima

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.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.