flutterfirebasepush-notificationfirebase-cloud-messaging

How to change notification icon sent from Firebase Cloud Messaging Flutter


So I'm learning about push notifications using Firebase Cloud Messaging using Flutter.

I've successfully displayed the notification in Android I sent from the Firebase console, but the problem is that the icon that appears doesn't match my app icon, like this: enter image description here

How do I change the icon? Thank You

UPDATE
So actually I think this is a problem with the form of assets that I provide. Because if the notification position comes in and you don't open the notification tray, then the icon is the color it should be.

But when you open the notification tray, the icon becomes gray, for some reason...

Because I saw several applications like that, one of which was even a bank application


Solution

  • You need to modify the Android configuration and provide a custom notification icon.

    Steps to change the notification icon:

    Place the custom notification icon in the appropriate location in your Flutter project (prefer a white silhouette icon on a transparent background) : android/app/src/main/res/drawable

    Ensure that the name of your icon matches the name in the next config file, here it will be notification_icon.png .

    Open the android/app/src/main/AndroidManifest.xml

    Add the following lines of code inside the <application> tag:

    <meta-data
    android:name="com.google.firebase.messaging.default_notification_icon"
        android:resource="@drawable/notification_icon" />
    

    The android:resource attribute should point to the custom notification icon you placed in the drawable folder.

    After rebuild it should be updated