node-push-notification
node-push-notification
is a library for sending push notifications from Node.js. Because
platforms (iOS, Android, AWS SNS, etc.) require different setups, node-push-notification
employs a transport system where helper modules are used to communicate with various push notification providers.
For example, node-push-notification
cannot send any push notifications out of the box, but if an Android transport plugin is used, it can send push notifications to Android devices. The plugin system is used to allow custom integrations, while keeping the dependencies of node-push-notification
to a minimum.
Basic Usage
The following example illustrates how node-push-notification
is integrated with Amazon's SNS service.
'use strict';const Push = ;const SnsTransport = ;const push = ; // Configure push notifications via AWS SNS.push; // Send a push notification via SNS.push;
API
node-push-notification
exports a single class with the following functions:
NodePush() constructor
A constructor function that takes no arguments.
NodePush.prototype.addTransport(transport)
- Arguments
transport
(object) - An instance of a transport for communicating with one or more push notification systems.
- Returns
- The
NodePush
instance.
- The
NodePush.prototype.send(platform, device, message, options, callback)
- Arguments
platform
(string) - The case insensitive platform name to send the push notification through. There must be a transport configured to handle the named platform or an exception will be thrown.device
(string) - The destination device ID of the push notification.message
(object) - An object containing the message to be sent. More details on the expected schema of this object will be included asnode-push-notification
matures.callback(err, result)
(function) - An optional callback function that passes the error and result of the send attempt.
- Returns
- The
NodePush
instance.
- The