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 206 forks source link

Notification not coming in notification Area #180

Closed purnendu9 closed 8 years ago

purnendu9 commented 8 years ago

Hi, I am trying to send messages. The messages are getting sent to the app. However the messages are not appearing in the notification area on top drawer.

The message object that gets sent is as below {"collapseKey":"Updates Avaliable","priority":"high", "contentAvailable":true, "delayWhileIdle":true, "restrictedPackageName":"XXXXXXXXXX", "data":{ "key1":"message1","key2":"message2","eventName":"ar","message":"Test Is this coming","route":"XX" }, "notification":{"title":"Hello from XX","icon":"mrkr1.png","body":"There is a New Appointment from My Best Guest"} }

When it reaches the client i see this object received is as below

{"title":"Hello from XXX","message":"Test Is this coming","additionalData":{"e":"1","icon":"mrkr1.png","key1":"message1","key2":"message2","eventName":"ar","route":"XX","collapse_key":"XXXX","foreground":true}}

Researched at lot of places as to how to get the event appear in notification Area as well. Documentation does not say musch about it also

hypesystem commented 8 years ago

How does your code look on the client side? Are you using the regular Android SDK?

This problem is likely because your client-side code does not support the notification field yet, because you are not using the GcmListenerService.

purnendu9 commented 8 years ago

its phonegap sdk exactly similar to https://github.com/ToothlessGear/node-gcm/issues/62 It may be something to do with the phonegap SDK but why should it work differently The git link for this is https://github.com/phonegap/phonegap-plugin-push

hypesystem commented 8 years ago

There have been issues with PhoneGap not supporting the notifications field previously. You should probably manually create the notification client-side based on the payload in data.

This is a PhoneGap Push plugin issue so I am closing it.

purnendu9 commented 8 years ago

You are right, Its not node gcm issue. However i debugged and was able to solve it. Just incase anyone stumbles here, The Phonegap plugin needs the 3 notification fields. phonegap plugin reads the title and the icon from the "notification" object however the message needs to be set in the "data" object.

Thanks for clarifying

eladnava commented 8 years ago

@purnendu9 Thanks for clarifying, I'm sure it will help other people in the future!