dpa99c / cordova-diagnostic-plugin

Cordova/Phonegap plugin to manage device settings
534 stars 354 forks source link

Android < 13 ACCESS_BACKGROUND_LOCATION is automatically granted despite it's not true #508

Closed askona closed 7 months ago

askona commented 7 months ago

I'm requesting when_in_use permission, and then, if it's granted, requesting always. The issue is that on Android lower then 13 always is not being requested, and I found why. JS: this.diagnostic.requestLocationAuthorization('**when_in_use**') // first dialog - is being showed up .then((status) => { return this.diagnostic.requestLocationAuthorization('**always**'); // this dialog is NOT showing on Android < 13 });

This is why it doesn't show second - it assumes _ACCESS_BACKGROUNDLOCATION is already granted. But as result - user still have "when_in_use" permission level. If I remove that line: permission.equals("ACCESS_BACKGROUND_LOCATION"), I'll be able to see both dialogs - request for when_in_use and for always

Screenshot 2023-11-09 at 10 36 59
dpa99c commented 7 months ago

I see the problem here: ACCESS_BACKGROUND_LOCATION was added in API 29 but this is assuming it was added in API 33. I should be able to make use of the min/max SDK definitions I added in a previous commit to resolve this.