nativescript-geolocation icon indicating copy to clipboard operation
nativescript-geolocation copied to clipboard

Android 11 has new requirements regarding background location permissions

Open klaus1978 opened this issue 4 years ago • 1 comments

Which platform(s) does your issue occur on?

-Android version 11+ -emulator / device

For Android 11+ a new location permission was added: "ACCESS_BACKGROUND_LOCATION"

In order to work in the background (e.g from a background service) you have to add that permission to the manifest. Additionaly it is necessary to ask the user to grant the permission to run in background, so user has to grant "Allow all the time"! But this grant is not visible in the plugin.

https://developer.android.com/training/location/permissions#request-background-location says you can get this label by processing: getBackgroundPermissionOptionLabel()

Is it possible to do that with this plugin?

Additionally when checking geolocation.isEnabled() I assume it is necessary to distinguish between the different types of location grants. Currently my app checks if it is enabled and returns TRUE, but then getCurrentLocation freezes as it does not have the correct grant ("Allow all the time")

KR Klaus

klaus1978 avatar Jun 01 '21 14:06 klaus1978

NativeScript 8 uses another package for geolocation: https://github.com/NativeScript/plugins/tree/main/packages/geolocation . The 'always' flag is already present there.

tomcoonen avatar Sep 09 '21 11:09 tomcoonen