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¶
Optional key-value metadata to attach to each location. Merged with any configured PersistenceConfig.extras before persisting or uploading to HttpConfig.url.
interval¶
Interval in milliseconds between location updates.
persist¶
Whether to persist each location to the SDK's SQLite database and upload
it to HttpConfig.url. Defaults to true when the SDK is enabled;
false when stopped.
timeout¶
Maximum time in milliseconds to wait for each location fix before
firing an error. Default 60000.