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:
- Create a custom notification icon using this tool.
- Paste the generated list of icons in
android/app/src/main/res
. - 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" />
- If you don't have a colors.xml in res/values, create one:
- 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.
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:
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
How to Add a Jar in External Libraries in Android Studio
How to Customize Listview Using Baseadapter
CSS Media Query - Soft-Keyboard Breaks CSS Orientation Rules - Alternative Solution
Updating Google Play Services in Emulator
Failed to Resolve: Com.Google.Firebase:Firebase-Core:11.2.0
Android Fragments and Animation
How to Align Views at the Bottom of the Screen
How to Display a List View in an Android Alert Dialog
How to Get the Width and Height of an Android.Widget.Imageview
Android Spinner: Get the Selected Item Change Event
How to Delete an Sms in Android Before It Reaches the Inbox
Android Studio Add External Project to Build.Gradle
How to Include *.So Library in Android Studio
Check Android Application Is in Foreground or Not
Open Application After Clicking on Notification
Android Background Music Service
Playing an Arbitrary Tone With Android
Push Notification Works Incorrectly When App Is on Background or Not Running