2.0.1 • Published 8 years ago

stratton v2.0.1

Weekly downloads
15
License
-
Repository
github
Last release
8 years ago

Stratton 2.0.1

A Node.js module for interfacing with Apple Push Notification, Google Cloud Messaging, Microsoft Push Notification and Amazon Device Messaging services.

Installation

$ npm install stratton

#Features

Usage

First of all:

IOS: replace cert.txt and key.txt files on stratton folder with your cert.pem and key.pem. 
ANDROID: Add to SETTINGS.js your API SERVER KEY on stratton folder.
FIRE OS: Add to SETTINGS.js your CLIENT ID and CLIENT SECRET on stratton folder.
OPTIONAL: Add to SETTINGS.js your PUSH TITLE (only compatible with IOS, Windows Phone and Fire OS) and PUSH MESSAGE (only compatible with Windows Phone and Fire OS);

Import stratton module:

var stratton = require('stratton');

Define JSON which includes the data you want to send and the pushId field having at least one destination device ID. You can send to multiple devices, independently of platform, creating an array with different destination device IDs.

// Single destination
var json = JSON.parse('{"pushId" : "INSERT_YOUR_DEVICE_ID", "data" : "INSERT_YOUR_DATA" }');

// Multiple destinations
var json = JSON.parse('{ "pushId" : ['INSERT_YOUR_DEVICE_ID1" , "INSERT_YOUR_DEVICE_ID2"] , "data" : "INSERT_YOUR_DATA" }');

Finally send a push notificacion and catch response:

stratton.sendPush(json, function (err,result){
    if (err)
        console.log('Error: ' + result);
    else
        console.log(result);
});

Result will contain 'OK' or 'an error description'.

##Resources