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

I sent the notification but It's not appears on Firebase Notifications #305

Closed jfbaquerocelis closed 6 years ago

jfbaquerocelis commented 6 years ago

Hi, I'm trying send notifications from my server to my android app but it's not works.

This is my code:

let sender = gcm.Sender('AIza***********************j8Yo');
let registrationTokens = ["AAAA7nujsgk:***********************************J"];
let message = new gcm.Message({
  priority : "high",
  notification: {
    title: "Hello, World",
    icon: "ic_launcher",
    body: "This is a notification that will be displayed if your app is in the background."
  },
});
sender.send(message, { registrationTokens : registrationTokens }, function (err, response) {
  if (err) console.error(err);
  else console.log(response);
});

The response is:

{ multicast_id: 7411791926489017000,
  success: 1,
  failure: 0,
  canonical_ids: 0,
  results: [ { message_id: '0:1503603462005768%0000000000000000' } ] }

But, My app is not showing the notification and on Firebase I don't see the notification in the panel. image

What is I doing wrong? Help me please :pray:

eladnava commented 6 years ago

Hi @jfbaquerocelis, Is there any chance that your app is in the foreground when you are testing to see if the notification was received?

As a reminder, sending a push notification with the notification field will only be displayed when your app is in the background.

Also, I believe the Firebase Console will only show notifications that you compose from within the Firebase Console itself, not ones sent via the FCM API.

eladnava commented 6 years ago

Closing due to lack of response. Feel free to reopen if you are still experiencing this.