Skip to content

Data types

Every type below is a named export re-exported from the package root, so you can import them directly for your own function signatures and component props:

import type { Location, State, Geofence } from '@dc-bgeo/react-native-background-geolocation';

Only the fields the app (and its backend) actually rely on are typed strictly here. A few object-shaped config and options types carry a permissive [key: string]: any index signature — unknown keys pass through uninterpreted rather than causing a type error.

Location & sensors

Location

The core location record. It’s the payload of onLocation and (when a fix exists) onMotionChange and onHeartbeat; the resolved value of getCurrentPosition(), watchPosition(), setOdometer()/resetOdometer(), and sync()/getLocations(); and the accepted shape for insertLocation() (as a Partial<Location>).

FieldTypeDescription
uuidstringUnique record id.
timestampstringISO-8601 UTC.
agenumberOptional. Fix age in milliseconds at the time it was processed.
odometernumberCumulative odometer reading, metres.
coordsCoordsPosition/motion fields.
activityMotionActivityClassified motion activity at the time of the fix.
batteryBatteryDevice battery snapshot.
is_movingboolean | nullMotion-state machine’s verdict at the time of this fix. null while a cold-started session’s first fixes are still in the unconfirmed-MOVING probing window — up to stopTimeout minutes after start(). The engine emits null there by design, so a server falls back to coords.speed instead of trusting a phantom “started moving”. Treat null the same as false.
samplebooleanOptional. true when this Location was resolved by getCurrentPosition() — either an existing fix served for a fresh-enough maximumAge, or the best (most accurate) of several fixes sampled internally — rather than delivered by the ambient tracking stream. The intermediate fixes collected while sampling for the best one are never themselves surfaced as separate Location records. Also true on the fix resolved by setOdometer()/resetOdometer() — that fix carries event: 'odometer' (see the event field below) rather than coming from getCurrentPosition().
eventstringOptional. Tags why this record was produced when it isn’t a plain tracked fix. Observed values: 'motionchange' (the record captured just before entering the stationary state) and 'odometer' (the fix resolved by setOdometer()/resetOdometer()).
extrasobjectOptional passthrough — e.g. { watch: true } on watchPosition() fixes, { heartBeat: true }, { getCurrentPosition: true }. Config-level extras form the base of every record; per-call extras are layered on top.

Snake_case: is_moving mirrors the wire format the native engines emit (camelCase elsewhere in this type, but this one field is snake_case — see also Coords and Battery below, which are almost entirely snake_case).

Coords

Nested inside Location.coords.

FieldTypeDescription
latitudenumberDegrees.
longitudenumberDegrees.
accuracynumberHorizontal accuracy, metres.
altitudenumberOptional. Metres above sea level.
altitude_accuracynumberOptional. Vertical accuracy, metres.
speednumberOptional. Metres/second.
speed_accuracynumberOptional. Metres/second.
headingnumberOptional. Degrees.
heading_accuracynumberOptional. Degrees.
ellipsoidal_altitudenumberOptional. Metres, WGS84 ellipsoidal (as opposed to altitude, which is mean-sea-level/geoid-based).

Snake_case: altitude_accuracy, speed_accuracy, heading_accuracy, and ellipsoidal_altitude are snake_case — they mirror the wire format the native engines emit, unlike latitude/longitude/accuracy/altitude/speed/heading.

MotionActivity

Nested inside Location.activity. Its type values are also the vocabulary accepted by config.triggerActivities (a CSV of these same strings).

FieldTypeDescription
type'still' | 'on_foot' | 'walking' | 'running' | 'on_bicycle' | 'in_vehicle' | 'unknown'Classified activity.
confidencenumberClassifier confidence for type.

Snake_case: the field names (type, confidence) are plain camelCase, but three of the type enum values themselves — on_foot, on_bicycle, in_vehicle — are snake_case, again mirroring the native wire format.

Battery

Nested inside Location.battery.

FieldTypeDescription
levelnumberBattery level, 0.01.0.
is_chargingbooleanWhether the device is currently charging.

Snake_case: is_charging mirrors the native wire format.

State

The tracker’s state snapshot: resolved by ready(), setConfig(), start(), stop(), and getState(). Every field past enabled is optional — State documents the superset of health/diagnostic fields either native engine may populate, not a fixed cross-platform guarantee, and the type’s own index signature ([key: string]: any) admits further engine-specific fields not listed here.

FieldTypeDescription
enabledbooleanWhether tracking is enabled (the persisted on/off intent).
trackingActivebooleanOptional. Whether the tracking engine currently has an active location request outstanding.
authorizationnumberOptional. One of the AUTHORIZATION_STATUS_* constants.
lastRawFixAgenumber | nullOptional, nullable. Diagnostic: age of the last raw fix (before filtering), in seconds. null until one arrives.
lastAcceptedFixAgenumber | nullOptional, nullable. Diagnostic: age of the last accepted fix (after filtering), in seconds. null until one arrives.
lastLocationErrorstring | nullOptional, nullable. Diagnostic: the most recent location error message.
locationFailureCountnumberOptional. Diagnostic counter.
backgroundRearmCountnumberOptional. Diagnostic counter.
watchdogRecoveryCountnumberOptional. Diagnostic counter.
wakeRearmCountnumberOptional. Diagnostic counter.
stationaryRegionArmedbooleanOptional. Diagnostic.
monitoredWakeRegionsnumberOptional. Diagnostic counter.
lastWakeErrorstring | nullOptional, nullable. Diagnostic: the most recent wake-region error message.
trackingModenumberOptional. Diagnostic.
isMovingbooleanOptional. Current motion-state-machine verdict — same value as onMotionChange’s isMoving.
schedulerEnabledbooleanOptional. Diagnostic.
odometernumberOptional. Cumulative odometer reading, metres.
geofenceCountnumberOptional. Diagnostic counter.
lastGeofenceErrorstring | nullOptional, nullable. Diagnostic: the most recent geofence-registration error message.
connectedbooleanOptional. Validated-internet connectivity — see ConnectivityChangeEvent.

Events

ProviderChangeEvent

Payload of onProviderChange and the resolved value of getProviderState() (same shape).

FieldTypeDescription
statusnumberOne of the AUTHORIZATION_STATUS_* constants3 is Always.
enabledbooleanWhether location services are on at all.
gpsbooleanGPS provider enabled.
networkbooleanNetwork provider enabled.
accuracyAuthorizationnumberOptional, iOS only — ACCURACY_AUTHORIZATION_FULL/REDUCED.

MotionChangeEvent

Payload of onMotionChange.

FieldTypeDescription
isMovingbooleantrue on the moving transition, false on the stationary transition.
locationLocationOptional (location?: Location | null) — absent (Android) or null (iOS) on the very first motionchange of a tracking session, before any fix exists yet (the initial probe fires from start() ahead of any location). Guard before dereferencing — see the Events reference for the same caveat.

GeofenceEvent

Payload of onGeofence.

FieldTypeDescription
identifierstringThe geofence’s identifier.
action'ENTER' | 'EXIT' | 'DWELL'The transition type.
locationLocationThe fix that triggered the transition.
extrasobjectOptional. The geofence’s own extras, echoed back.

GeofencesChangeEvent

Payload of onGeofencesChange — a delta of the OS-registered subset, not the full persisted set (see Geofence below and the Geofencing guide).

FieldTypeDescription
onGeofence[]Geofences newly registered with the OS.
offGeofence[]Geofences just unregistered.

HttpEvent

Payload of onHttp — fired once per completed location-sync HTTP request (log uploads do not emit this event; see the logging guide).

FieldTypeDescription
successbooleantrue when status is 2xx.
statusnumberHTTP status code; 0 when the request never got a response (network error).
responseTextstringResponse body (or the error message when status is 0), truncated to 1024 characters.

ConnectivityChangeEvent

Payload of onConnectivityChange. Fired on validated-internet transitions (Android NET_CAPABILITY_VALIDATED / iOS NWPath.satisfied — a captive-portal Wi-Fi network reports false); a newly-registered listener also immediately receives the current state as a synthetic first delivery.

FieldTypeDescription
connectedbooleanValidated-internet reachability.

Geofencing

Geofence

A persisted geofence definition — the shape accepted by addGeofence()/addGeofences() and returned by getGeofences() and the on/off arrays of GeofencesChangeEvent. See the Geofencing guide for validation rules, proximity slicing, and DWELL semantics.

FieldTypeDescription
identifierstringUnique geofence id.
radiusnumberMetres.
latitudenumberDegrees.
longitudenumberDegrees.
notifyOnEntrybooleanOptional.
notifyOnExitbooleanOptional.
notifyOnDwellbooleanOptional.
loiteringDelaynumberOptional. Milliseconds; required alongside notifyOnDwell for a DWELL transition.
extrasobjectOptional. Echoed back on the corresponding GeofenceEvent.

Positioning options

CurrentPositionOptions

Parameter of getCurrentPosition().

FieldTypeDescription
persistbooleanOptional. Whether the resolved fix is added to the upload queue like a normal tracked point.
samplesnumberOptional. Number of fixes to sample before returning the best (most accurate) one.
timeoutnumberOptional. Seconds to wait before giving up. Default 30.
maximumAgenumberOptional. Accept a cached fix up to this many milliseconds old instead of sampling a new one.
desiredAccuracynumberOptional. One of the DESIRED_ACCURACY_* constants.
extrasobjectOptional. Merged into the returned location’s extras.

WatchPositionOptions

Parameter of watchPosition().

FieldTypeDescription
intervalnumberOptional. Desired update interval, milliseconds.
desiredAccuracynumberOptional. One of the DESIRED_ACCURACY_* constants.
persistbooleanOptional. Whether fixes are added to the upload queue.
extrasobjectOptional. Merged into each returned location’s extras.

Logging

LogEntry

Resolved array-element type of getLog(); written by logger.error/warn/info/debug/verbose and the native engine itself. See the logging guide for retention and upload cadence.

FieldTypeDescription
tsstringISO-8601 UTC.
levelnumber1=ERROR, 2=WARN, 3=INFO, 4=DEBUG, 5=VERBOSE.
src'native' | 'js'Whether the line originated in the native engine or app-side JS (logger.* calls).
eventstringShort event tag.
messagestringOptional. Human-readable log line.
dataanyOptional. JSON-serialized data attached to the line.

Headless

HeadlessEvent

Parameter of the task passed to registerHeadlessTask() Android . Unlike every other event type on this page, there is no params/payload wrapper — the event’s payload fields are flattened alongside name directly on the same object (enforced by the type’s [key: string]: any index signature). iOS never invokes a registered headless task at all, since there’s no AppRegistry-driven headless service on that platform — see registerHeadlessTask() and the boot & killed-app guide.

FieldTypeDescription
name'heartbeat' | 'motionchange' | 'geofence' | 'providerchange' | 'powersavechange' | 'http' | 'connectivitychange'The event type. The union matches the Android engine’s headless dispatch set exactly; 'location' is deliberately not part of it — see below.
[key: string]anyThe rest of the event’s fields, flattened alongside name — e.g. a headless motionchange carries isMoving/location directly on this object, not nested under a params key.

No headless location: the Android engine never dispatches a location event headlessly, and the union reflects that — the runtime set of headless-dispatched event names is exactly heartbeat, motionchange, geofence, providerchange, powersavechange, http, and connectivitychange, so narrowing on event.name is exhaustive. High-frequency location fixes are deliberately excluded to avoid spinning up Android’s HeadlessJsTaskService (and a wakelock) per fix while tracking, which would drain battery and risk ANRs/foreground-service-start restrictions; fixes taken while the JS context isn’t running are still durably queued and uploaded natively. This mirrors the same note under onLocation on the Events reference.

Subscriptions

Subscription

Returned by every on* listener method on the Events reference.

FieldTypeDescription
remove() => voidDetaches this one listener. To tear down every listener at once, call removeListeners() instead.