flutter-permission-plugins icon indicating copy to clipboard operation
flutter-permission-plugins copied to clipboard

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

Open galunecandrey opened this issue 4 years ago • 2 comments

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.

galunecandrey avatar Sep 18 '20 16:09 galunecandrey

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).

diegogarciar avatar Jan 14 '21 20:01 diegogarciar

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

@diegogarciar that's helpful. Thanks!

viirak avatar Sep 16 '21 15:09 viirak