Node.js REST API Quick Start
Installation
Using npm:
npm install scaledrone-node-push --save
Using Yarn:
yarn add scaledrone-node-push
Usage
Create a new instance of Scaledrone passing it the channelId
and secretKey
that you can find from your channel's page from Scaledrone's dashboard.
const Scaledrone = require('scaledrone-node-push');
const sd = new Scaledrone({
channelId: 'CHANNEL_ID',
secretKey: 'SECRET_KEY'
});
Sending messages
Rooms are used to isolate different message types. To listen to messages, you need to subscribe to a specific room.
Users can freely connect to multiple rooms (this does not create extra connections).
const message = {foo: 'bar'};
const room = 'notifications';
sd.publish(room, message, function(error) {
// check for errors
});