Skip to content
Support the creatorSupport

State & status types

All types are exported from the package:

import { AuthorizationStatus, type State, type ProviderState } from 'react-native-long-ping';

Resolved by configure(), setConfig(), start(), stop(), getState() and changePace().

interface State {
enabled: boolean;
isMoving: boolean;
lastLocation: Location | null;
lastLocationAt: number | null;
queueCount: number;
authorizationRequired: boolean;
config: ResolvedConfig;
}
Field Meaning
enabled Tracking is on (start() was called and not stop()). Saved on the device; survives restarts.
isMoving Current state: moving or parked.
lastLocation The last recorded location record, or null.
lastLocationAt When it was recorded, epoch milliseconds, or null.
queueCount Records waiting to be uploaded.
authorizationRequired An upload got 401/403 and the token could not be refreshed. Cleared by setAuthorization() or a successful upload.
config The full resolved config: every key filled in with its value or default.

Resolved by getProviderState() and delivered by onProviderChange.

interface ProviderState {
enabled: boolean;
gps: boolean;
network: boolean;
status: AuthorizationStatus;
accuracyAuthorization: 'full' | 'reduced';
powerSaveMode: boolean;
ignoringBatteryOptimizations: boolean;
}
Field Meaning
enabled Location services are switched on.
gps The GPS provider is available.
network The network location provider is available.
status Location permission, as an AuthorizationStatus.
accuracyAuthorization 'reduced' when the user turned off precise location.
powerSaveMode The phone’s battery saver / Low Power Mode is on.
ignoringBatteryOptimizations Android: the app is exempt from battery optimization. Always true on iOS.

A number. Use the exported constants rather than the raw values.

export const AuthorizationStatus = {
NOT_DETERMINED: 0,
RESTRICTED: 1,
DENIED: 2,
ALWAYS: 3,
WHEN_IN_USE: 4,
} as const;
Value Name iOS Android
0 NOT_DETERMINED Not asked yet. Nothing granted and the app can still ask.
1 RESTRICTED Blocked by the system or device management. Not used.
2 DENIED Refused. Nothing granted, the app asked before, and Android will no longer show the dialog.
3 ALWAYS “Always”. Fine or coarse, plus background.
4 WHEN_IN_USE “While Using”. Fine or coarse, without background.

On iOS the values map directly from CLAuthorizationStatus, in Apple’s order except that 3 and 4 are swapped.

Config, HttpConfig, ResolvedConfig, Location, Coords, LocationEvent, Accuracy, LogLevel, Authorization, CurrentPositionOptions, GetLogOptions, MotionChangeEvent, HttpEvent, AuthorizationEvent, EnabledChangeEvent, ErrorEvent, ErrorCode and Subscription. They are documented on the Config, Methods, Events and Location record pages.