flutter_local_notifications icon indicating copy to clipboard operation
flutter_local_notifications copied to clipboard

Make Android permissions optional

Open emersion opened this issue 2 years ago • 2 comments

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?

emersion avatar Sep 01 '22 07:09 emersion

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

MaikuB avatar Sep 03 '22 10:09 MaikuB

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"/>

noinskit avatar Sep 07 '22 08:09 noinskit

This will help https://www.youtube.com/watch?v=aQTvI8L-mZs

myselfuser1 avatar Mar 17 '23 12:03 myselfuser1

As a note, you must include the tools namespace in the manifest tag for that to work:

xmlns:tools="http://schemas.android.com/tools"

IcedNet avatar Jun 14 '23 14:06 IcedNet

This has been done as part of the 16.0.0 prerelease

MaikuB avatar Jul 16 '23 10:07 MaikuB