How to change remote push notification icon for React Native(android) application

Viewed 31078
4 Answers

You have to follow some rules for notification icon link

First, generate notification icons link of all sizes. and put the icon name ic_notification.

Then move all sizes ic_notification in the respective folder in the android/app/main/res/mipmap folder and add below line in AndroidManifest.xml file.

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

you should first add the new icon in all android/app/src/main/res/mipmap-*

notice in all folders that start mipmap-* add new icon with same name with proper resolution

then in your notification object that send you can add it's name

{
  largeIcon: "ic_launcher", // (optional) default: "ic_launcher"
  smallIcon: "ic_notification", // (optional) default:  "ic_notification" with fallback for "ic_launcher"
}

PushNotification.configure({
  largeIcon: "ic_launcher",
  smallIcon: "ic_notification",
}) 

I found solution by adding below code in AndroidManifest.xml before application closing tag:

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

Before generate icon please keet it in mind logo should have transparent background

Generate notification icons link of all sizes and put the icon name notification_icon and extract all drawable-density/ folders inside res folder

Related