Geo Tracking - Specs

How geolocation works

Consent-based collection, native and test positions, and the limits of background tracking.

What the system collects

Geo Tracking is a route tracking lab. The app records positions supplied by the operating system, saves each position on the device, and sends authenticated batches to the API. The dashboard displays the received history and lets users change collection parameters.

The implementation lives in the local GeoMonitoring Expo module, written in Kotlin and Swift. The React Native app handles the interface, consent, connection setup, and simulation; continuous collection and transport of real positions run in native code.

The same module contains two independent flows:

FlowPurposePersistenceDelivery
TrackingRecord and transmit a routeNative SQLiteReal HTTP with acknowledgment by ID
PolygonsDemonstrate classification, entry, and proximityNative preferencesSimulated state changes

The polygon demo does not filter the route sent to the API. Starting one flow does not automatically start the other.

From tapping Start to the dashboard

  1. The app configures endpoint, deviceId, and the device credential. Configuring a connection does not authorize collection.
  2. The user reads the background location disclosure and starts tracking through the interface.
  3. The flow checks location access while in use, requests background location access, and asks for notification permission on supported Android versions.
  4. The native module persists local authorization and activates the platform's location provider.
  5. Each valid position receives an eventId, its source, and the current configuration version.
  6. The position enters SQLite before any HTTP attempt.
  7. The transport sends up to 100 positions per request; only acknowledged IDs leave the queue.
  8. The server persists the batch and publishes new positions to dashboards connected over WebSocket.

The return value of startTracking() or syncTracking() is a snapshot of the process state. It does not mean a position has already reached the server. Subsequent counts and events show the outcome of the asynchronous operation.

Who controls collection

The system separates local authorization from remote permission to collect:

Field or actionMeaning
configuredA connection has been configured; this does not prove current connectivity
authorizedThe user started a local session that has not been stopped
enabledNative collection is active according to the service state
Remote tracking.enabledAllows or pauses collection within a locally authorized session
Local stopRevokes the local session and stops collection

A remote pause preserves local authorization. If the configuration allows collection again and the process gets an opportunity to run, the same session can continue. This is why the Stop tracking button remains available even when collection is paused remotely.

A local stop has a different effect: remote configuration does not create new authorization. Pending records remain in the queue and can synchronize after the stop; stopping collection does not erase history.

A position record

FieldSource and interpretation
eventIdUUID created on the device; remains unchanged across retries
latitude and longitudeFinite coordinates within valid geographic bounds
accuracyMetersHorizontal accuracy reported by the source, from 0 to 10,000 meters
capturedAtCapture timestamp in ISO 8601 format
providernative for a system callback; test for synthetic injection
configVersionConfiguration version known when the event was created
receivedAtAdded by the server when persisting the event

accuracyMeters is neither distance traveled nor error measured against an external reference. It is an estimate supplied by the provider or the test.

Capture and receipt timestamps serve different purposes. An old position can arrive after connectivity recovers; that does not make it the most recent position along the route.

Native and synthetic positions

provider:native identifies positions received through the native callback. A route applied to an emulator or simulator's GPS also follows this callback and receives this source. That result demonstrates integration with the simulated system, not a route traveled on a physical device.

injectTrackingLocation() always stores provider:test, even if the supplied object specifies another source. The sample uses the same SQLite queue and HTTP transport as tracking. This exercises persistence, retries, and the dashboard without claiming that real movement occurred.

Route simulation is controlled by the app. It can use a current system position as its starting point, but the generated steps remain synthetic. Running the route depends on the JavaScript interface's lifecycle.

The server keeps latestByProvider.native and latestByProvider.test separately. Selection uses capturedAt, with eventId as a tiebreaker; a recent synthetic sequence does not hide the latest native position.

Collection parameters

ParameterInitial valueAccepted range
tracking.enabledtrueBoolean
distanceFilterMeters10 meters0 to 1,000 meters
intervalSeconds5 secondsInteger from 1 to 300 seconds
version1Positive integer

On Android, distance and interval are part of a high-accuracy request to the Fused Location Provider. On iOS, distance is applied to CLLocationManager, and the interval filters callbacks before positions are persisted.

The interval is a request or a filter, depending on the platform. It does not promise exactly one sample every N seconds. GPS availability, movement, permissions, and execution time granted by the system affect the results.

The current code does not implement activity detection to switch automatically between stationary and moving modes. It also does not measure battery consumption to choose accuracy dynamically.

Offline behavior

Collection can continue saving positions while transport fails. Each service allows only one synchronization at a time, retries with increasing delays, and attempts delivery when connectivity returns.

The app exposes pendingCount, uploadedCount, lastSyncAt, and lastError. The queue does not automatically discard old records to make room for new ones. If persistence fails, collection stops or pauses with an explicit error.

A successful HTTP response without acknowledged IDs from the batch does not empty the queue. See Queue and synchronization for the complete explanation.

Background execution and resumption

On Android, a location foreground service maintains a notification and provides a stop action. The system may recreate the service while the session remains authorized, without guaranteeing resumption after every type of termination.

On iOS, CLLocationManager uses the background location capability. Synchronization takes advantage of callbacks, connectivity notifications, and execution windows. After a remote pause completely stops location updates, a suspended process does not automatically receive another execution window just because the server configuration changed.

Persisting authorization and the queue does not guarantee collection during force-stop, device reboot, or manufacturer power restrictions. The repository records simulator trials; Field testing describes evaluation on physical devices.

Where the feature is available

A native build containing the local module is required. The web implementation returns an unavailable state and rejects native tracking configuration, start, synchronization, and injection.

The web dashboard consumes the API and displays positions. It does not replace the location service in the installed app.

Repository sources

  • geo-demo/modules/geo-monitoring/src/GeoMonitoringModule.ts
  • geo-demo/modules/geo-monitoring/src/GeoMonitoringModule.web.ts
  • geo-demo/src/features/tracking/start-tracking.ts
  • geo-demo/src/features/tracking/native-tracking.ts
  • geo-demo/modules/geo-monitoring/android/src/main/java/expo/modules/geomonitoring/TrackingEngine.kt
  • geo-demo/modules/geo-monitoring/ios/GeoTrackingService.swift
  • tracking-server/src/index.ts
  • docs/tracking-contract.md
  • docs/validation-2026-10-15.md

On this page