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:
And I want my icon to look like this:
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?
The
android:resource
(@folder
/name
)in themeta-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 namedic_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
inandroid/app/src/main/res/values
which will contain yourcolorPrimary
:Extra: The
android:icon
in theapplication
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.