jlcvp / fcm-node

A Node.JS simple interface to Google's Firebase Cloud Messaging (FCM) for Android & iOS & Web Notification and data push
MIT License
125 stars 46 forks source link

I am facing InvalidServerResponse while sending notification #80

Closed mrafiqk closed 3 years ago

mrafiqk commented 3 years ago

I am not able to send any notification to my android or ios device. We upgraded to a newer version, but our notification still fails. I have attached my sample code here. Please let me know if need to change anything. But it worked fine before. The same code now fails.

       var message = {
          to: doc.token,
          collapse_key: 'green',
          notification: {
            title: title,
            body: body
          }
        };
        if(image) {
          message.notification.image = image;
        }
        fcm.send(message, function (err, response) {
          if(err) {
            reject(err);
          } else {
            resolve(response);
          }
        })
ismailceliktr commented 3 years ago

I have same problem. Any idea?

I am not able to send any notification to my android or ios device. We upgraded to a newer version, but our notification still fails. I have attached my sample code here. Please let me know if need to change anything. But it worked fine before. The same code now fails.

       var message = {
          to: doc.token,
          collapse_key: 'green',
          notification: {
            title: title,
            body: body
          }
        };
        if(image) {
          message.notification.image = image;
        }
        fcm.send(message, function (err, response) {
          if(err) {
            reject(err);
          } else {
            resolve(response);
          }
        })
jlcvp commented 3 years ago

Google may have deprecated the sdk version I use or maybe they change the message format. I'll investigate and see if it's worth updating the lib

ismailceliktr commented 3 years ago

My problem was entirely my fault. I manually set the FCM API ip addresses in /etc/hosts for my firewall rules. Requests to an IP address get stuck in the firewall. After rearranging my firewall settings, my problem was solved.

jlcvp commented 3 years ago

I am not able to send any notification to my android or ios device. We upgraded to a newer version, but our notification still fails. I have attached my sample code here. Please let me know if need to change anything. But it worked fine before. The same code now fails.

       var message = {
          to: doc.token,
          collapse_key: 'green',
          notification: {
            title: title,
            body: body
          }
        };
        if(image) {
          message.notification.image = image;
        }
        fcm.send(message, function (err, response) {
          if(err) {
            reject(err);
          } else {
            resolve(response);
          }
        })

@mrafiqk based on @ismailceliktr testimony, can you check your network settings to see if the firebase host is accessible?

mrafiqk commented 3 years ago

@jlcvp I think the problem is my token. I regenerated my token and sent my notification again. It works fine.