Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have followed this link for push notification implementation within my app https://github.com/zo0r/react-native-push-notification/tree/a359e5c00954aa324136eaa9808333d6ca246171

at present the default app launcher icon is displayed. I want to change it. Is there any way to do that?

like image 692
Anu Avatar asked Sep 21 '17 12:09

Anu


People also ask

How do I change my push notifications icon?

Navigate to Messages > New Push > Platform Settings > Google Android Options > Set the icon name without the file extension. With Large Notification Icons, you can also supply a URL where the icon will be displayed from.

How do I change notification icons on Android?

1 Tap Notification Settings on the notification panel or tap the Settings app. 2 Tap Notifications. 3 Tap App icon badges.

How do you change the icon of app in Android in React Native?

Open Android Studio and run your React-native project. In Android Studio's Project window, select the Android view. Right-click the res folder and select New > Image Asset.


2 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" />

like image 175
rahulworld Avatar answered Sep 19 '22 18:09

rahulworld


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",
}) 
like image 20
Mohamed Khalil Avatar answered Sep 19 '22 18:09

Mohamed Khalil