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

Setting `smallIcon` and` LargeIcon` for Android client #330

Closed verybluebot closed 5 years ago

verybluebot commented 5 years ago

From my understanding of the docs (and testing)

when you specify icon it acctually smallIcon on android how can I set the largeIcon

and if this even exists?

PS: im working with React Native on the client but ok with setting a hard coded small and large icons in the native code

I test this in my AndroidManifest.xml :

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

but this sets the small icon (if its in the right size and not colored) I want to hard code the largeIcon or pass it in some way using this library is this possible?

thanks

verybluebot commented 5 years ago

ok after more digging in the native code on the client I tried to send smallIcon and largeIcon instead of icon and it worked.. this should really be in the docs a lot of time wasted here..

hypesystem commented 5 years ago

Hey @verybluebot ! Thanks for pointing this out. We would appreciate a PR adding the documentation, if you have the time :smile: it sounds like a great addition!

verybluebot commented 5 years ago

@hypesystem this does not work on when on notification key.. only on body and only when message key is added (otherwise it will be a silent notification that would not go to notification center on client thus trigger nothing...

the first part of this mite be the handling of the React Native library im using on client but im not sure have not dug deep enough on this...

hypesystem commented 5 years ago

@verybluebot I think we've heard about that issue before, where that particular library expects a slightly odd format. However, the documentation of smallIcon and largeIcon would still be welcome :smile:

verybluebot commented 5 years ago

ok so ill add it with a warring note :/ wait for it...

eladnava commented 5 years ago

Hi @verybluebot, That is indeed not directly caused by node-gcm, as it is a very specific implementation decision made by the react-native push notification library you are using, to supply icons in the notification payload. The FCM documentation does not endorse this, it is a format that only your RN plugin expects, and they have documented it on their GitHub page. 👍

verybluebot commented 5 years ago

@eladnava yes you are definitely right problem is they don't have documentation for that either, I figure it out by digging the plugins native classes.. maybe it should be mentioned in this library this uses case because Im assuming there are more RN users like me that will need to implement it in this way

eladnava commented 5 years ago

@verybluebot I believe it should only be mentioned in the RN library which has this quirky implementation, we can't go and keep track of and document every unofficial client library's quirky implementation details. node-gcm is a server-side library used for interfacing with the FCM APIs. Using 3rd-party unofficial client plugins is up to you.

Instead, create a PR in the RN library and document this quirky implementation there. 👍

verybluebot commented 5 years ago

@eladnava "quirky" is the exact word... and its the "main"/go to library for handling push notifications on RN.. yes.. this does not belongs here.. I got tired on these type of issues working with RN to be honest. I think Ill go more towards native development in future projects.