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

Duplicate notifications #267

Closed lego72 closed 8 years ago

lego72 commented 8 years ago

We are using Firebase cloud messaging. Sometimes when Android or iOS app is in sleep mode the cell phone receives same (duplicates) notifications messages. For device identifications the FIRInstanceID token is used. An external server on node.js is used for sending notifications to Firebase service. No duplications in our server log file are presented.

hypesystem commented 8 years ago

That sounds very odd indeed!

What kind of messages are these? Are you sending to a single device at a time, or to multiple devices? Maybe several tokens are active for a single device?

Otherwise, I don't have many suggestions. Do you think you can share some code of how you send the notifications? Preferably including the lookup of recipients to send to. This would help us understand what is going on, and what might be going wrong :-)

Thank you for taking the time to file an issue!

eladnava commented 8 years ago

Closing due to lack of response. Please reopen if you still experience this issue.

clareluna commented 7 years ago

Hi,

I came across this issue, and am actually experiencing it myself. My system is built to send a single device a notification at a time. The notification I am sending consists of a title, sentence long text body, app icon, and default sound. The push notification is destined for android devices only.

I have confirmed that only one token is active when sending the notification and have printed out the response object which also is showing that only one notification is being sent. However, my device receives duplicate notifications for each call.

Here is the code I am using image

I have also attempted to use the default callback function for sending notifications and am still seeing duplicate notifications. Below is the printout of the response object from a single send call.

image

We are running node-gcm 0.14.6.

Please let me know if you need more information from me and thanks for your help!! Clare

hypesystem commented 7 years ago

Hi Clare,

Hmm... I think it is more likely that the error should be found where you call your sendGcmMessage function.

Can you clarify: are your devices always receiving two of each message, or are they receiving more and more copies of each subsequent message sent?

It doesn't seem that anything is wrong with the way you use node-gcm, but I don't know promisify, so I can't be entirely sure :-)

Any chance you could show us some of the code that triggers sendGcmMessage? Sending duplicate messages could result from something like binding an event listener too many times. (I see that you are stating that your code only prints one log message, but this would be interesting to look at anyway to get a bigger picture view into what is going on.)

By the way, this would have probably been better off as an entirely new issue :-)

clareluna commented 7 years ago

Good call :) here's the new issue --> https://github.com/ToothlessGear/node-gcm/issues/302