I have recently been trying to send push notification to my android and ios devices. For ios I found that node-apn module will be used for handling this,but for android I haven't come across anything of that sort. Any help will be much appreciated.
2 Answers
There is another alternative; android-gcm. It is super easy to use.
Code sample from documentation:
var gcm = require('android-gcm');
// initialize new androidGcm object
var gcmObject = new gcm.AndroidGcm('API_KEY');
// create new message
var message = new gcm.Message({
registration_ids: ['x', 'y', 'z'],
data: {
key1: 'key 1',
key2: 'key 2'
}
});
// send the message
gcmObject.send(message, function(err, response) {});
2 Comments
Venkatesh Voona
Here, registration Id's means, Where we can get ?
Chris Timberlake
@VenkateshVoona - Hey, You've probably figured this out by now. But the Registration ID is the ID your app gets for that device when it registered for push notifications. You'll want to save those ID's when the App Registers itself with the Push Service.
Check these solutions for more info.
https://github.com/SpeCT/node-c2dm
2 Comments
Amanda G
thanks for the information. Will this work for the new android gcm? If u know anything regarding that please do help me
Serdar Dogruyol
Probably will work for the new gcm.But you better check the docs for each one.