flutter firebase push notification icon

7.2k views Asked by At

I made an app and I implemented push notifications and it works but I've tried to change the default icon with a image.png but it's not working the way that I expected. This is how my notification looks: enter image description here

And I want my icon to look like this:

enter image description here

I've added in my android manifest this:

<!-- Add custom icon to the notifications -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_notifications" />
<!-- Change the color of the icon -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorPrimary" />

I don't know what I've done wrong but can you help me?

1

There are 1 answers

0
Underscore On BEST ANSWER

The android:resource (@folder/name)in the meta-data tag refers to the notification icon should be located in android\app\src\main\res\ folder-size\ name.png.

For your exact scope, you need the drawable-size folder in the specific location with pngs named ic_notifications. I suggest you use this amazing tool to generate all the required icons with the correct layout (white on transparent).

Because you also have a color for your notification, you must add the colors.xml in android/app/src/main/res/values which will contain your colorPrimary:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#FFFFFF</color>
</resources>

Extra: The android:icon in the application tag refers to the app's icon. Just want to add this extra piece of information because it can be confusing at first when the example found are pretty similar.