Baseflow / flutter-permission-plugins

This repo contains a collection of permission related Flutter plugins which can be used to request permissions to access device resources in a cross-platform way.
https://baseflow.com
MIT License
52 stars 33 forks source link

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

Open galunecandrey opened 4 years ago

galunecandrey commented 4 years ago

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:

On IOS all good.

diegogarciar commented 3 years ago

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 commented 3 years ago

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

@diegogarciar that's helpful. Thanks!