Push Notification Services Abstraction
It works the same for GCM or WNS. You just have to change the structure of the parameters object. And that's it !
var Pnotifier = require('pnotifier').Service;
var service = new Pnotifier({
protocol: 'apn',
credentials: {
cert: 'cert_path.pem',
key: 'key_path.pem'
},
options: {
...
}
});
service.createConnection(function (err) {
service.send(['list_of_devices_token','...'],
{
alert: 'Hello World!',
payload: {
messageFrom: 'Thomas from Evertygo'
}
},
function (err) {
service.close();
}
);
});
All the options
are the same as the node-apn package.
But with a particular structure as described below.
var apnConfig = {
credentials: {
cert: 'cert_path.pem',
key: 'key_path.pem',
},
options: {
// node-apn options (except cert, key and token)
}
};
All the options
are the same as the node-gcm package.
But with a particular structure as described below.
var gcmConfig = {
credentials: {
api_key: '...',
},
options: {
// node-gcm options (except api_key and tokens)
}
};
All the options
are the same as the wns package.
But with a particular structure as described below.
var wnsConfig = {
credentials: {
client_id: '...',
client_secret: '...',
channelURI: '...'
},
options: {
// node-apn options (except client_id, client_secret and channelURI)
}
};
Pnotifier is open-source licensed under the MIT license