Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
  • Apr 17 19:15
    ademir10 commented #350
  • Apr 17 13:42
    eladnava closed #350
  • Apr 17 13:42
    eladnava commented #350
  • Apr 16 20:56
    ademir10 opened #350
  • Feb 23 09:32

    ToothlessGear on master

    1.0.4 (compare)

  • Feb 23 09:28

    ToothlessGear on master

    use request@2.88.0 upgrade lodash Merge pull request #349 from ma… (compare)

  • Feb 23 09:28
    ToothlessGear closed #349
  • Feb 23 09:28
    ToothlessGear commented #349
  • Feb 23 09:27
    ToothlessGear commented #337
  • Feb 23 09:27

    ToothlessGear on master

    fix: Gcm InternalServerError sh… added similar test cases. Merge pull request #337 from yo… (compare)

  • Feb 23 09:27
    ToothlessGear closed #337
  • Feb 23 03:21
    jannomeister commented #349
  • Jan 20 20:40
    marneborn opened #349
  • Dec 11 2020 19:54
    davimacedo closed #348
  • Dec 11 2020 19:54
    davimacedo opened #348
  • Oct 29 2020 10:25
    medoix closed #347
  • Oct 29 2020 10:25
    medoix commented #347
  • Oct 29 2020 10:14
    medoix opened #347
  • Jul 25 2020 03:18
    eladnava commented #340
  • Jul 25 2020 03:18
    eladnava commented #340
Henry Tseng
Is anyone using this in production right now?
hello :o:
this works with FCM?
Marcus Farkas
Yes it does! see #255
@henrytseng AFAIK Instagram uses it, as does surespot, and various push libraries
Debjeet Sarkar
yes using it in prod
Brad Wertman
Screen Shot 2016-08-31 at 5.35.30 PM.png
How does the “Server Key” of FCM fit in with the node-gcm configuration?
Does that get passed to new gcm.Sender(’SERVER_KEY’);

Hello, i try this, i found error401. var gcm = require('node-gcm');
var apiKey = "AIzaSyDxxs9S8uvjiQJcvml09narkc_dIpAY1gs";
var deviceID = "ftUAFGfn8xg:APA91bGun-NEejGn30reWXK5wyidMK094AP02a3ACFcGotBiM3eeDEhSTZKI-6vs63bGKfJ4ffcBD9ZEVc2L6X1fT0jtf7YtwJtRBqO_WMByFKoASaRRYFHQyVCUmvc3nmBmx";

var service = new gcm.Sender(apiKey);
var message = new gcm.Message();
message.addData('title', 'Hello, World');
message.addData('body', 'This is a notification that will be displayed ASAP.');

service.send(message, { registrationTokens: [ deviceID ] }, function (err, response) {
if(err) console.error(err);
else console.log(response);

Pls help me how to correct it. I m using phonegap-plugin-push in my app.
Debjeet Sarkar
unauthorised server api key ,sir
You need to create a new project under FCM and provode the new ones.
I will try, thank you.
Daniel Beicht

Hi, I'm new to FCM and node-gcm and try to get it run. With the Example-application I get a success-response but the notification doesn't appear on my test device?
var gcm = require('node-gcm');

// Set up the sender with your GCM/FCM API key (declare this once for multiple messages)
var sender = new gcm.Sender('AAAAhziPlIg**');

// Prepare a message to be sent
var message = new gcm.Message({
data: { key1: 'nodetest' }

// Specify which registration IDs to deliver the message to
var regTokens = ['eFtDerXHzCE:APA91bGEnICDH6B**'];

// Actually send the message
sender.send(message, { registrationTokens: regTokens }, function (err, response) {
if (err) console.error(err);
else console.log(response);

When I try it via FCM Webinterface it works fine.

{ multicast_id: 472217287575,
success: 1,
failure: 0,
canonical_ids: 0,
results: [ { message_id: '0:149572594411101%a00
' } ] }

try sending this message instead:

const notification = new gcm.Message({
priority: 'high',
contentAvailable: true,
delayWhileIdle: false,
timeToLive: 3,
restrictedPackageName: 'your app id here ex: com.xxx.xxxxxx',
dryRun: false,
notification: {
title: 'liveScores',
icon: 'ic_launcher',
sound: 'default',
body: 'your notificaiton message here'

it should work.
notification key should not be blank I found.
Niels Abildgaard

Hi all!

Today, a lot of (all?) Android devs got an email saying that by April 11, 2019 we must migrate from using the old GCM infrastructure to the new Firebase Cloud Messaging. I just wanted to let you all know that node-gcm already uses FCM and has since version 0.14.1 :-) Feel free to ask more questions here: ToothlessGear/node-gcm#317


Tarek Moubarak
Hello all! I want to check how can I use async/await while sending multiple messages
Niels Abildgaard
Hey! Right now the short answer is that you can't :-(
You would need to wrap the interface in a Promise to do so.
Alternatively, you could write your own wrapper:
let sendPromise = new Promise((resolve, reject) => sender.send(message, { registrationTokens: regTokens }, (error, response) => {
    if(error) {
    else {
This would let you do await sendPromise.
Tarek Moubarak
alright fantastic will try it now ... thank you! also will async/await e available in version 2.0.0?
Niels Abildgaard
We are not even at 1.0.0. If you want to work on adding a promise API to the library, I would be happy to guide you through it :)
Tarek Moubarak
Would love to! this library is very useful
Tarek Moubarak
just let me know how to proceed
also the above solution worked very well for me :D
thak you!
Niels Abildgaard

The first step would be figuring out which methods we need to provide promisified versions of. I am thinking that an easy interface to expose would be something like sender.promise.send, which would be the promisified version of sender.send?

To do this, you would have to create a promise object on Sender's prototype in here: https://github.com/ToothlessGear/node-gcm/blob/master/lib/sender.js and then make sure that promise has a function send which returns a promise.

Does that approach sound reasonable to you? If so, I'd love to see your code for doing this. You can make an early PR and we can discuss it further there :-)

Let me know if you need any more pointers, I'm never quite sure how much to explain :-)
Tarek Moubarak
alright awesome @hypesystem will take a look!
Hello! I am having a bit of an issue with sending the notification. The Android app receives only when the app is closed and I have no idea why. Besides that, how could I make a voip notification. You can see the code here: http://prntscr.com/ljl4wn. Thank you!
Augusto Gonzalez
That's not a real problem
As far as I remember you have to send in app notifications in order to send that.
Foreground notifications are not supported anymore on Android