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 34 forks source link

Location permission level has no effect on checking or requesting permissions. #41

Closed mlemos closed 4 years ago

mlemos commented 4 years ago

🐛 Bug Report

This bug has two wrong behaviors:

First: When checking for location permission status using the permission level parameter, the results are always the same independently of the permission level passed as parameter.

Second: If your project requires permission for always, the systems return denied for all permission levels if you have not granted the always permission. It doesn't differentiate the WhenInUse for the WhenInUse level.

It seems that it is missing the capability to return the propper permission status when "While In Use" is granted. Even if the query (check) is using the LocationPermissionLevel.locationWhenInUse is used in the method call.

Expected behavior

I understand that the correct behavior would be to return the proper permission granted for permission level checked.

Reproduction steps

You can use the sample application to reproduce the error. I'm running the tests in a Nexus 4 API 29 emulator.

Check the sequences below to reproduce the error:

Screen Shot 2020-05-24 at 11 51 15 AM Screen Shot 2020-05-24 at 11 51 12 AM Screen Shot 2020-05-24 at 11 51 08 AM

Configuration

My AndroidManifest.xml has the following lines:

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />

My build.gradle is set for:

compileSdkVersion 29
...
targetSdkVersion 29

Version: 2.0.5

Platform:

mlemos commented 4 years ago

Other questions?

a) how to know if the user granted permission for ALWAYS or ONLY WHEN IN USE.

b) what is the difference, in the example, of the results from LocationPermissions().checkPermissionStatus() and the await LocationPermissions() .requestPermissions(permissionLevel: permissionLevel). It seems that the results are inconsistent between these two calls. As they should have the same results (after the user has permanently granted or not the permissions).

mvanbeusekom commented 4 years ago

@mlemos thank you very much for thanking the time and write this great and detailed bug report. It is really appreciated.

I have just released a hotfix (version 3.0.0+1) which (thanks to @filipproch) includes a fix for this issue. It also includes a fix for iOS which showed similar behavior (requesting "when-in-use" permissions also resulted in the plugin falsely reporting "always" permission were granted).

Regarding you other questions:

a) With this hotfix the plugin will now take the supplied PermissionLevel into consideration. So if you want to only request "when-in-use" permissions, you can call await LoctionPermissions().requestPermissions(permissionLevel: PermissionLevel.locationWhenInUse).

b) The checkPermissionStatus method is meant to only check if permissions are currently granted. The requestPermissions method is meant to really ask the user for permissions (if not yet permanently denied or granted).

Hope this helps. I will close the issue for now but please feel free to let me know if you have questions or if the problem still remains.

guihackmann commented 4 years ago

Hi @mvanbeusekom

I followed all steps above, updated to the latest version, and I still 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.