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

Message notification appears in notification tray #303

Closed idoadse closed 6 years ago

idoadse commented 6 years ago

Hey guys im using your library for firebase push notifications. I want to implement a mechanism to allow sending a user notification without having a new notification on the notification tray (i.e. I just want the PN mechanism to notify my app, rather than notify the user). By the FCM specs it seems like a FCM message containing only "message" part (I don't send the "notification" key on the final json at all), is supposed to do the job, but I get notified on these message as well. If it matters, my app is nativescript app, and my push notification receiving library is 'node-gcm' (https://github.com/NativeScript/push-plugin#android-configuration-for-using-firebase-cloud-messaging)

I have tried many combinations but none seemed to work. Does it supposed to be supported? Thanks

eladnava commented 6 years ago

Hi @idoadse, According to the NativeScript push-plugin documentation, they have programmed a push receiver that builds and displays a notification even if the notification fields are not set in the push notification request:

Handling Data Messages The onMessageReceived method of the plugin is called each time a data notification is received. When in background mode, a notification is constructed according to the values of the key specified above and placed in the tray. Tapping the notification launches the app and invokes the onMessageReceived callback.

This logic is implemented in the plugin in these lines: https://github.com/NativeScript/push-plugin/blob/71ed5f7be6eb09ce746f3aa63eebb9d575d5ec2a/native-src/android/app/src/main/java/com/telerik/pushplugin/PushPlugin.java#L128-L136

It appears that you may need to modify the plugin to change this behavior, as it does not support any configuration that will prevent it from building a notification when your app is in the background.

eladnava commented 6 years ago

There is actually an open issue for this missing functionality in push-plugin: https://github.com/NativeScript/push-plugin/issues/100

Closing this as it is unrelated to node-gcm.

idoadse commented 6 years ago

Many thanks, was not thinking about client side issue. Thanks for the great work on the library!