HaylLtd / cordova-background-geolocation-plugin

Background and foreground geolocation plugin for Cordova.
Apache License 2.0
56 stars 64 forks source link

Permission is reported as denied if it's set to Ask Every Time #169

Closed jwasnoggin closed 10 months ago

jwasnoggin commented 10 months ago

Describe the bug In Android 11+, if the location permission for the app is set to "Ask Every Time", rather than asking the user for permission it just says that permission is denied.

To Reproduce Steps to reproduce the behavior:

  1. Go to Android settings and set the Location permission for the app that uses this plugin to "Ask Every Time"
  2. Attempt to start geolocation in the app

Expected behavior The user should be asked to grant permission

Screenshots A permission denied message is shown

Smartphone (please complete the following information):

Additional context I noticed that this plugin is using a very old version of io.github.nishkarsh:android-permissions (0.1.7). Could be that updating to the latest version of this (2.1.8) might help? This is a breaking change of course so would require other code changes as well.

HarelM commented 10 months ago

You should be able to update the dependency locally, compile the app and test it. If this works, feel free to submit a PR.

jwasnoggin commented 10 months ago

Any tips on how to test and compile the plugin locally? I'm not familiar with native Android development.

HarelM commented 10 months ago

Search in google for the relevant platform (capacitor/cordova) for how to run android studio with your app and you should be able to debug it.

jwasnoggin commented 10 months ago

Turns out this error was actually coming from navigator.geolocation.getCurrentPosition and not from this plugin. So I'll close this issue.

I did manage to update the permissions plugin though (changes here). Not sure if it's worth merging.

HarelM commented 10 months ago

Using an updated version is probably a good idea, so it'll be great if you could open a PR with this change.

jwasnoggin commented 10 months ago

Done: #171