requestLocationAuthorization() returns DENIED_ALWAYS for cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS
Closed this issue · 1 comments
Bug report
CHECKLIST
-
[Y ] I have read the issue reporting guidelines
-
[Y ] I confirm this is a suspected bug or issue that will affect other users
- [Y ] I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
- [Y ] I have read the documentation thoroughly and it does not help solve my issue.
- [Y ] I have checked that no similar issues (open or closed) already exist.
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
-
Cordova CLI version
cordova -v
- 10.0.0
-
Cordova platform version
cordova platform ls
- android 10.1.1
-
Plugins & versions installed in project (including this plugin)
cordova plugin ls
cordova-plugin-androidx-adapter 1.1.3 "cordova-plugin-androidx-adapter"
cordova-plugin-androidx 1.0.2 "cordova-plugin-androidx"
cordova-plugin-device 2.0.3 "Device"
cordova-plugin-file 6.0.2 "File"
cordova-plugin-geolocation 4.1.0 "Geolocation"
cordova.plugins.diagnostic 6.1.0 "Diagnostic"
-
Dev machine OS and version, e.g.
-
mac OS Big Sur 11.6.1
- OSX
sw_vers
- Windows 10
winver
- OSX
Runtime issue
- Device details
- e.g. iPhone X, Samsung Galaxy S8, iPhone X Simulator, Pixel XL Emulator
- Google Pixel 5
- OS details
- e.g. iOS 12.2, Android 9.0
- Android Version 11
Android build issue:
- Node JS version
node -v
- v10.15.3
- Gradle version
ls platforms/android/.gradle
- 7.1.1
- Target Android SDK version
android:targetSdkVersion
inAndroidManifest.xml
- android:targetSdkVersion="30
- Android SDK details
sdkmanager --list | sed -e '/Available Packages/q'
iOS build issue:
- Node JS version
node -v
- XCode version
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:
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.