Android GCM Client for Node.js
A simple interface for Google Cloud Messaging (GCM) in Node.js
Installation
$ npm install android-gcm
Usage
Simplest Usage
var gcm = ; // initialize new androidGcm objectvar gcmObject = 'API_KEY'; // create new messagevar message = registration_ids: 'x' 'y' 'z' data: key1: 'key 1' key2: 'key 2' ; // send the messagegcmObject;
Message Class
// You can initialize the message object as an empty object and alter it later.var message = ; // add new value to data object (as key-value)message; // OR add new value(s) to data objectmessage; // add new registration_id (device token)message;message; // OR add many registration ids at oncemessage; // other message optionsmessagecollapse_key = 'urgent_news';messagedelay_while_idle = false; // The message should not be sent immediately if the device is idle.messagetime_to_live = 11; // How long (in seconds) the message should be kept on GCM storage if the device is offline.messagedry_run = false; // If true, test the request without actually sending a message
For full list of message options, check payload table here.
Debugging Requests to GCM Server
To debug requests made to GCM server, set DEBUG=https
.