ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 208 forks source link

Custom icon for notification #315

Closed muhsin-k closed 6 years ago

muhsin-k commented 6 years ago

Hi Guys. Thanks for your awesome work. Can we set an icon for a custom push notification icon, as an addition to the app's icon & splash screen from the server?

eladnava commented 6 years ago

Hi @muhzi4u, Are you referring to iOS or Android push notifications?

muhsin-k commented 6 years ago

Both android and ios

eladnava commented 6 years ago

FCM only lets you set the notification icon for Android notifications, using the icon parameter, which must be the name of a @drawable/ resource included with the app:

// as object
message.addNotification({
  title: 'Alert!!!',
  body: 'Abnormal data access',
  icon: 'ic_launcher'
});

https://github.com/ToothlessGear/node-gcm#notification-usage

Shivendra30 commented 5 years ago

Hi @eladnava , I have tried the above steps to add the icon to the android notification through node-gcm however the icon still does not appear. Is there a change or what can I be doing wrong?

eladnava commented 5 years ago

Hi @Shivendra30, Please make sure you placed your icon file in your drawables-* folder in PNG format with the same name the icon parameter passed to message.addNotification().

Shivendra30 commented 5 years ago

Hi @eladnava , I did that but it did not work Then I found out that For 5.0 Lollipop "Notification icons must be entirely white". This post helped me out - https://stackoverflow.com/questions/30795431/android-push-notifications-icon-not-displaying-in-notification-white-square-sh :)

eladnava commented 5 years ago

Ah, nice catch 👍

verybluebot commented 5 years ago

this is working, but... sending the white (very small icon) as the image appear next to the title and message. the desirable end result is to have the small icon next to a main large avatar image, like on FB how can that be achieved?

the result im getting is the icon specified above as the large icon in the image and the small one and there is no small one..

if I don't send icon value at all I get the app icon as the main and a small empty white square on the bottom right icon_example