dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
540 stars 361 forks source link

requestLocationAuthorization() returns DENIED_ALWAYS for cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS #450

Closed asuraj closed 2 years ago

asuraj commented 2 years ago

Bug report

CHECKLIST

Current behavior:

When we request for “Always” location permission, it won’t open the dialog that asks for permission and instead just returns a denied_always in the success handler i.e when we call cordova.plugins.diagnostic.requestLocationAuthorization(..,.., cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS) When we ask for “When In Use” location permission, the dialog comes up but the location pings will not come when app is in background. So user will need to go and set the “Always” permission manually from settings. We are able to reproduce this issue on the sample also: https://github.com/dpa99c/cordova-diagnostic-plugin-example. We hit this issue after upgrading to Android API level 30 and cordova-android 10.1.1. We upgraded to latest diagnostic plugin version 6.1.0 and the issue is still reproducible.

Expected behavior:

We expect the location permission dialog to come up so user can grant location 'ALWAYS' permission. Steps to reproduce:

Launch cordova-diagnostic-plugin-example and click on "Request Location Authorization Always". Screenshots

Environment information

Runtime issue

Android build issue:

iOS build issue:

Related code:

insert any relevant code here such as plugin API calls / input parameters

cordova.plugins.diagnostic.requestLocationAuthorization(..,.., cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS) Console output

console output ``` // Paste any relevant JS/native console output here ```


**Other information:**
asuraj commented 2 years ago

This is an issue due to Android restricting access to background location permissions directly: https://developer.android.com/training/location/permissions#request-background-location Closing the issue.