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

Android Permission Best Practices #30

Open
1 task
DavidCorrado opened this issue Feb 16, 2020 · 3 comments
Open
1 task

Android Permission Best Practices #30

DavidCorrado opened this issue Feb 16, 2020 · 3 comments

Comments

@DavidCorrado
Copy link

🏗 Enhancement Proposal

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.

Pitch

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
A. The library does not automatically show the location services enable dialog. This library does if you need a code reference https://github.com/loup-v/geolocation
B/C. 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 not redirect the user to the settings page or show the dialog before as I think it should. So maybe when requesting permission we can pass this message and you show it in a dialog before going to the settings page. Also might want to expose the neverAskAgain like you have in here
https://github.com/Baseflow/flutter-permission-handler/blob/develop/lib/src/permission_enums.dart
D. It would be great if when requesting permission that the permission rational could be passed in so your library would show the dialog and after they confirm they get taken to the grant page again.

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

  1. Show enable location services dialog when its disabled
  2. Return denied forever from the permissions enum. Give developer option to redirect user to app settings if denied forever. Also show a dialog before redirecting to app settings that the developer can send in the text for.
  3. Have permission rational be something we pass in when requesting permissions so the library can handle showing it and showing the grant permission dialog.

Platforms affected (mark all that apply)

  • 📱 iOS
  • [X ] 🤖 Android
@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

@Nathan-Heller
Copy link

I'd like to upvote this proposal. I do not believe there is a trivial way to differentiate between 'denied once' and 'denied forever', which makes it difficult to show the appropriate modal dialogs/direct the user to the correct location to update their settings.

Are there any status updates on this proposal (and its sister proposal #31 )?

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

2 participants