NativeScript / nativescript-geolocation

Geolocation plugin to use for getting current location, monitor movement, etc
Apache License 2.0
139 stars 76 forks source link

Android 11 has new requirements regarding background location permissions #279

Open klaus1978 opened 3 years ago

klaus1978 commented 3 years ago

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

tomcoonen commented 3 years ago

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