3

I want to set a custom notification icon to appear in my notifications panel for my flutter app when i use fcm(firebase cloud messaging) but there is only a grey circle that appears and no icon .

austin
  • 517
  • 5
  • 16

1 Answers1

9

After Searching for a long time i finally found the answer and here it is:

  1. Create a custom notification icon using this tool.
  2. Paste the generated list of icons in android/app/src/main/res.
  3. Go to your manifest android/app/src/main/AndroidManifest.xml and add the following meta data in the application (not activity) tag:
<meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
    android:resource="@drawable/ic_notification" />
<meta-data
    android:name="com.google.firebase.messaging.default_notification_color"
    android:resource="@color/colorPrimary" />
  1. If you don't have a colors.xml in res/values, create one: enter image description here
  2. Done! It should work, let me know if it doesn't.

Discussion for the question is here.

Oleg Yablokov
  • 736
  • 8
  • 19
austin
  • 517
  • 5
  • 16
  • Little sidenote: The tool (Notification icon generator) names the icons sometimes in a strange way. To make the above configuration work, you need to rename every icon to ic_notification before you copy the icons into the ```android/app/src/main/res``` folder. Second point, to make the color work, rename the ```colorAccent``` in the colors.xml to ```colorPrimary```. That't is! – Chris Nov 16 '22 at 22:34