BrowserLocationPermissionRequester

Observes and requests browser geolocation permission.

BrowserLocationProvider delegates LocationProvider.permission and LocationProvider.requestPermission to an instance of this class. Construct one with a CoroutineScope to back a custom LocationProvider.

PermissionStatus.state maps granted to LocationPermission.Granted, prompt to LocationPermission.NotGranted with canRequest = true, and denied to canRequest = false. A browser without the Permissions API reports canRequest = null until an explicit request determines the result. A missing Geolocation API maps backendAvailability to LocationBackendAvailability.Unsupported.

Constructors

Link copied to clipboard
constructor(coroutineScope: CoroutineScope)

Creates a requester whose permission observation runs in coroutineScope. Cancelling the scope stops the observation.

Properties

Link copied to clipboard

Whether the browser has a usable Geolocation API.

Link copied to clipboard
val status: StateFlow<LocationPermission>

Current foreground location permission.

Functions

Link copied to clipboard

Starts a foreground permission request and returns immediately.