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

Device.getLocation

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

Feature description

Get the device's current location once. Use it when you need the current location, such as for maps, weather, or finding stores. To continuously detect location changes, Device.subscribeLocationuse

If you don't have location permission, GetCurrentLocationPermissionErroroccurs. Device.getLocation.getPermission() / Device.getLocation.openPermissionDialog()you can check/request permission with

Type

Device.getLocation(options: GetCurrentLocationOptions): Promise<Location>;

Params

enum Accuracy {
  Lowest = 1, // Error range within about 3KM
  Low = 2, // Error range within about 1KM
  Balanced = 3, // Error range within a few hundred meters
  High = 4, // Error range within about 10M
  Highest = 5,
  BestForNavigation = 6,
}

type GetCurrentLocationOptions = {
  accuracy: Accuracy;
};

Response

Error

The error is thrown as a class — error instanceof GetCurrentLocationPermissionErroridentify it with. The class can @apps-in-toss/web-frameworkbe imported from

Error class
Description

GetCurrentLocationPermissionError

This means location permission was denied. Device.getLocation.openPermissionDialog()You can request again with

Example code

Was this helpful?