Skip to content

WatchPositionRequest

export interface WatchPositionRequest {

Options for BackgroundGeolocation.watchPosition.

Configures the interval, accuracy, persistence, and metadata for a continuous location stream. All fields are optional.

Warning

watchPosition is intended for foreground use. On iOS it prevents the app from being suspended, which drains the battery. Remove the subscription when your app moves to the background.

const subscription = BackgroundGeolocation.watchPosition(
  { interval: 1000, desiredAccuracy: DesiredAccuracy.High },
  (location) => {
    console.log("[watchPosition]", location);
  },
  (errorCode) => {
    console.warn("[watchPosition] error:", errorCode);
  }
);

// Later, stop watching.
subscription.remove();

Members

desiredAccuracy

desiredAccuracy?:DesiredAccuracy;

Target accuracy for location updates from the native API. Defaults to DesiredAccuracy.High.

extras

extras?: Record<string, any>;

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

interval

interval?: number;

Interval in milliseconds between location updates.

persist

persist?: boolean;

Whether to persist each emitted location to the SDK's SQLite database and upload it to HttpConfig.url.

An explicit value is authoritative — it overrides PersistenceConfig.persistMode and the SDK's enabled state. When omitted, persistence follows persistMode: each location is stored only while the SDK is enabled and persistMode includes the location bucket (PersistMode.All or PersistMode.Location).

persist SDK enabled persistMode Persisted?
true any any
false any any
(omitted) stopped any
(omitted) enabled PersistMode.None / PersistMode.Geofence
(omitted) enabled PersistMode.Location / PersistMode.All

Setting PersistenceConfig.maxRecordsToPersist to 0 disables all persistence, overriding even an explicit persist: true.

timeout

timeout?: number;

Maximum time in milliseconds to wait for each location fix before firing an error. Default 60000.