Skip to content
This repository has been archived by the owner on Oct 5, 2021. It is now read-only.

Issue with the checkPermissionStatus on Android when the user selects "Allow only while using the app" #51

Open
galunecandrey opened this issue Sep 18, 2020 · 2 comments

Comments

@galunecandrey
Copy link

galunecandrey commented Sep 18, 2020

Hi!

I updated to the latest version(3.0.0+1), and I have an issue with the checkPermissionStatus on Android when the user selects "Allow only while using the app".
Basically, when the prompt appears in Android:

  • If the user click in "Allow all the time", checkPermissionStatus return "granted" (which is fine)
  • If the user clicks in "Deny", checkPermissionStatus return "denied", (also fine)
  • If the user clicks in "Allow only while using the app", checkPermissionStatus return "denied" (here is the problem). But requestPermissions return "granted".

On IOS all good.

@diegogarciar
Copy link

Hello, I thought this was an issue too but I found the following, maybe it helps others too.

When you check permission status you can specify the permission level to check:
checkPermissionStatus(level: LocationPermissionLevel.locationWhenInUse)

the default is LocationPermissionLevel.location, so if the user only granted whenInUse, the default call for permissions will be "denied".

Depending on your requirements you can check different permission levels, to display different messages. So if you see that you have permission for whenInUse but not for always, you can tell the user why you want to access the location at al times.

In my scenario I only needed whenInUse, so I just asked whenInUse permission locationPermissions.requestPermissions( permissionLevel: LocationPermissionLevel.locationWhenInUse); and checked for whenInUse access checkPermissionStatus(level: LocationPermissionLevel.locationWhenInUse).

@viirak
Copy link

viirak commented Sep 16, 2021

PermissionStatus permissionInUse = await LocationPermissions().checkPermissionStatus(level: LocationPermissionLevel.locationWhenInUse);

@diegogarciar that's helpful. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants