For the complete documentation index, see llms.txt. This page is also available as Markdown.

Device.subscribeLocation

Functional API startUpdateLocationYou can use the same function with this as well.

Feature description

Continue detecting changes in the device's location, and whenever the location changes onEvent call the callback. You must unsubscribe with the returned cleanup function. timeIntervalmay be longer than the specified value due to system effects.

If you don't have location permission, onError to the callback StartUpdateLocationPermissionError(GetCurrentLocationPermissionErrorand an instance of the same class) is passed. Device.subscribeLocation.getPermission() / Device.subscribeLocation.openPermissionDialog()you can check/request permission with

Type

Device.subscribeLocation(params: StartUpdateLocationEventParams): () => void;

Params

type StartUpdateLocationEventParams = {
  onEvent: (location: Location) => void;
  onError: (error: unknown) => void;
  options: {
    accuracy: Accuracy;
    /** Minimum location update interval (ms). */
    timeInterval: number;
    /** Distance (m) to detect location changes. */
    distanceInterval: number;
  };
};

Response

cleanup function that unsubscribes (() => void).

Error

The error is onError is passed to the callback as a class instance — error instanceof StartUpdateLocationPermissionErroridentify it with. The class can @apps-in-toss/web-frameworkbe imported from

Error class
Description

StartUpdateLocationPermissionError

when location update permission is denied. Device.subscribeLocation.openPermissionDialog()You can request again with

Example code

Was this helpful?