Full documentation for this SDK can be found here
The Beams Node.js server SDK is available on npm here.
You can install this SDK by using npm:
$ npm install @pusher/push-notifications-server --save
Or yarn if you prefer:
$ yarn add @pusher/push-notifications-server
Use your instance id and secret (you can get these from the dashboard) to create a Beams PushNotifications instance:
const PushNotifications = require('@pusher/push-notifications-server');
let pushNotifications = new PushNotifications({
instanceId: 'YOUR_INSTANCE_ID_HERE',
secretKey: 'YOUR_SECRET_KEY_HERE'
});
Once you have created your Beams PushNotifications instance you can publish a push notification to your registered & subscribed devices:
pushNotifications.publish(['hello'], {
apns: {
aps: {
alert: 'Hello!'
}
},
fcm: {
notification: {
title: 'Hello',
body: 'Hello, world!'
}
}
}).then((publishResponse) => {
console.log('Just published:', publishResponse.publishId);
}).catch((error) => {
console.log('Error:', error);
});