node-push-notification-sns-transport
node-push-notification-sns-transport
provides an interface for sending push notifications via AWS SNS. This module is meant to be used with node-push-notification
, but can be used as a standalone module.
Basic Usage
The following example illustrates how node-push-notification
integrates with node-push-notification-sns-transport
.
'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-sns-transport
exports a single class with the following functions:
NodePushSnsTransport() constructor
- Arguments
options
(object) - An optional configuration object supporting the following schema:sns
(object) - An optional aws-sdk SNS. If provided, it is used for all AWS API calls. If not provided, a new instance is created.aws
(object) - An optional configuration object passed to the aws-sdk SNS constructor. This value is ignored if thesns
option is present.platformAppArn
(string) - An optional ARN corresponding to the SNS platform application used by this instance. Defaults toundefined
.
- Returns
- Nothing
NodePushSnsTransport.prototype.platform
This property informs node-push-notification
of the backends supported by this module. This value defaults to 'sns'
.
NodePushSnsTransport.prototype.send(platform, device, message, options, callback)
- Arguments
platform
(string) - The case insensitive platform name to send the push notification through. This must be'sns'
or the method will throw.device
(string) - The destination device ID of the push notification. If theisEndpoint
option is set,device
will be treated as a platform application endpoint ARN. This allows the endpoint creation API call to be skipped.message
(object) - An object containing the message to be sent.options
(object) - A configuration object that supports the following fields:isEndpoint
(boolean) - Iftrue
, thedevice
argument is treated as a platform application endpoint ARN. Defaults tofalse
.platformAppArn
(string) - The platform application ARN used when creating the application endpoint. If present, this option overrides anyplatformAppArn
passed to theNodePushSnsTransport
constructor. This option is ignored ifisEndpoint
istrue
because the endpoint creation API call is skipped. Defaults toundefined
.
callback(err, result)
(function) - A callback function that passes the error and result of the send operation.
- Returns
- The
NodePushSnsTransport
instance.
- The