flutter_local_notifications
flutter_local_notifications copied to clipboard
Make Android permissions optional
Right now the plugin requires the app to have a bunch of permissions:
https://github.com/MaikuB/flutter_local_notifications/blob/d3553c5e4a98dcc5366e48a365194ef19ebd3da5/flutter_local_notifications/android/src/main/AndroidManifest.xml#L3-L7
There is no way for applications to remove these permissions, even if they do not use features that require them. For instance, an app which only posts regular notifications does not need RECEIVE_BOOT_COMPLETED
, USE_FULL_SCREEN_INTENT
, nor SCHEDULE_EXACT_ALARM
.
Other plugins (e.g. flutter_background
, or even Flutter itself with the INTERNET
permission) ask developers to manually add the permissions they need in their docs.
Would it be possible to do the same here, so that developers can remove permissions they don't need when using the plugin?
Thanks for raising this. Actually, the setting up of permissions use to be something the plugin required each app to do. This did lead to occurrences where issues would be raised as some of the community missed this step. Moreover, this change was driven by a review from the Flutter ecosystem committee when they were evaluating the plugin for the Flutter favourites program and mentioned this would reduce friction in using the plugin. I could look at moving these out so the plugin itself isn't requesting permissions besides the bare minimum but to be safe, will check with the committee if they have concerns on this happening
FYI as a workaround, permissions merged from the plugin's AndroidManifest.xml can be removed in app's own AndroidManifest.xml like this:
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" tools:node="remove"/>
This will help https://www.youtube.com/watch?v=aQTvI8L-mZs
As a note, you must include the tools namespace in the manifest tag for that to work:
xmlns:tools="http://schemas.android.com/tools"
This has been done as part of the 16.0.0 prerelease