Skip to content

CurrentPositionRequest

export interface CurrentPositionRequest {

Options for BackgroundGeolocation.getCurrentPosition.

All fields are optional. The SDK always requests location from the native API at maximum accuracy (DesiredAccuracy.High), regardless of the desiredAccuracy threshold set here.

const location = await BackgroundGeolocation.getCurrentPosition({
  timeout: 30,          // seconds before giving up
  maximumAge: 5000,     // accept a cached fix up to 5000 ms old
  desiredAccuracy: 10,  // stop sampling when accuracy ≤ 10 m
  samples: 3,           // take up to 3 samples and pick the best
  extras: {
    route_id: 123
  }
});

Members

desiredAccuracy

desiredAccuracy?: number;

Accuracy threshold in meters. The SDK stops sampling as soon as it receives a location with accuracy ≤ desiredAccuracy and returns it immediately. Defaults to GeoConfig.stationaryRadius.

Note

This value is a stopping threshold, not a hardware accuracy setting. The SDK always requests locations at DesiredAccuracy.High from the native API regardless of this value.

extras

extras?: Record<string, any>;

Optional key-value metadata to attach to the returned location. Merged with any configured PersistenceConfig.extras before persisting or uploading to HttpConfig.url.

maximumAge

maximumAge?: number;

Accept the most recently recorded location if it is no older than this value in milliseconds. Default 0 (always fetch a fresh fix).

persist

persist?: boolean;

Whether to persist the returned location to the SDK's SQLite database and upload it to HttpConfig.url. Defaults to true when the SDK is enabled; false when stopped.

samples

samples?: number;

Maximum number of location samples to collect before returning the most accurate result. Default 3. Only the final selected location is persisted.

timeout

timeout?: number;

Maximum time in seconds to wait for a location fix. Default 30.

If the timeout expires before a satisfactory location is found, the Promise rejects with a LocationError.