Notification Icon with the New Firebase Cloud Messaging System

Notification Icon with the new Firebase Cloud Messaging system

Unfortunately this was a limitation of Firebase Notifications in SDK 9.0.0-9.6.1. When the app is in the background the launcher icon is use from the manifest (with the requisite Android tinting) for messages sent from the console.

With SDK 9.8.0 however, you can override the default! In your AndroidManifest.xml you can set the following fields to customise the icon and color:

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

Note that if the app is in the foreground (or a data message is sent) you can completely use your own logic to customise the display. You can also always customise the icon if sending the message from the HTTP/XMPP APIs.

How to set a Flutter Custom Notification Icon ?,because there is no default notification icon in flutter for fcm

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:
    Sample Image
  2. Done! It should work, let me know if it doesn't.

Discussion for the question is here.

FCM Custom Notification Icon in flutter

I was able to set custom notification and custom sound or custom icon via local notification while using push notification in flutter.

1

2

project detail

Firebase Notification icon is gray

The icon to be used for notifications must be white-colored and with transparent background else it will show a grey-colored box.

You can check out this article to know more.

I had the same problem and resolved it by making changes to the icon image.

Here's a sample image:
Notification Logo

Android Firebase notification gives default icon

<!-- Set custom default icon. This is used when no icon is set for incoming notification messages.
-->
<meta-data
android:name="com.google.firebase.messaging.default_notification_icon"
android:resource="@drawable/ic_stat_ic_notification" />
<!-- Set color used with incoming notification messages. This is used when no color is set for the incoming
notification message. -->
<meta-data
android:name="com.google.firebase.messaging.default_notification_color"
android:resource="@color/colorAccent" />

Check this link for more details https://firebase.google.com/docs/cloud-messaging/android/receive



Related Topics



Leave a reply



Submit