Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Permission Best Practices #55

Open
DavidCorrado opened this issue Feb 16, 2020 · 2 comments
Open

Android Permission Best Practices #55

DavidCorrado opened this issue Feb 16, 2020 · 2 comments

Comments

@DavidCorrado
Copy link

I have been evaluating the popular location permission libraries with flutter to see how it matches with the best practices. Below is what I found with your library. Let me know if there are ways to get this to work that I missed.

Android Best Practices
https://developer.android.com/distribute/best-practices/develop/runtime-permissions
https://developer.android.com/training/permissions/requesting
So below is my understanding of the best practices.

if (Location Services Disabled)
    A) Show Location Services Dialog 
else if (Location Services Enabled)
    If(Permission Denied Forever)
        B) Show Dialog that says permission denied forever and will show Settings
            C) Redirect to app settings
    else if(Denied Once && Permission Rational provided)
        D) Show Permission Rational
                  Show Permission Dialog
    else
        E) Show Permission Dialog

So the library does not support
B. So if permissions are denied forever I would think it would be best to show some sort of dialog before redirecting the user to the settings page. The library does redirect the user to the settings page but let's say I want to show a dialog. I could set openSettingsIfDenied to false but I have no way to discern between denied forever and just denied.

D. The library has no means to show the permission dialog after it was denied once. Which is when the permission rational would be shown. Also android returns when you should show this which the API should expose.
E. I failed this one because if someone denys once they will never see the dialog again.

Summary
I think these are the changes required for users of the library to implement permissions.

  1. Keep showing the permission dialog if not denied forever
  2. Be able to get back that google says to show permission rational. Also would be good if there was a way to pass that rational while requesting location and it shows that as a dialog. Could use this same rational for deny forever dialog.
  3. Get back from response if denied vs denied forever

Let me know if you need any clarification.

@DavidCorrado
Copy link
Author

Added a repo with Android and iOS examples of this best practice for review of how this works and for clarification and to validate things I said above are possible
https://github.com/DavidCorrado/LocationPermissions

@DavidCorrado
Copy link
Author

I created a specific example of how to do what I think is best practices as a flutter plugin here. This example is really specific for my usecase but I think you could make it more flexible for a use in a plugin. Feel free to take any of my code or ideas from this example
https://github.com/DavidCorrado/LocationPermissions/tree/master/Flutter/location_services_permissions

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

No branches or pull requests

1 participant