1.0.1 • Published 4 years ago
@engagespot/notifications v1.0.1
Engagespot NodeJS SDK
Easiest way to implement user-specific web push notifications in Nodejs web apps.
Engagespot helps you to add push notification functionality to your node web application. Before using this SDK, you need to create a free account at https://engagespot.co Add push notifications to your NodeJS web app in less than 10 mins!
Features
Installing
Using npm:
$ npm install @engagespot/notifications
Example
Typescript usage:
import { createInstance } from '@engagespot/notifications';
const apiKey = process.env.API_KEY || '';
const siteKey = process.env.SITE_KEY || '';
const engagespotInstance = createInstance({
apiKey,
siteKey,
});
engagespotInstance
.setMessage({
campaign_name: 'User Message Alert',
notification: {
title: 'You have a new message from John!',
message: 'Hey Dave, Wassup...',
icon: 'https://cdn.yourwebsite.com/images/profiles/john.jpg',
url: 'https://app.yourwebsite.com/messages',
},
send_to: 'identifiers',
})
.addIdentifiers(['123'])
.send()
.then((res) => {
console.log(`
status: ${res.status}
time: ${res.time}
message: ${res.message}
`);
})
.catch((err) => {
throw err;
});
CommonJS usage:
const { createInstance } = require('@engagespot/notifications');
const apiKey = process.env.API_KEY || '';
const siteKey = process.env.SITE_KEY || '';
const engagespotInstance = createInstance({
apiKey,
siteKey,
});
engagespotInstance
.setMessage({
campaign_name: 'User Message Alert',
notification: {
title: 'You have a new message from John!',
message: 'Hey Dave, Wassup...',
icon: 'https://cdn.yourwebsite.com/images/profiles/john.jpg',
url: 'https://app.yourwebsite.com/messages',
},
send_to: 'identifiers',
})
.addIdentifiers(['123'])
.send()
.then((res) => {
console.log(`
status: ${res.status}
time: ${res.time}
message: ${res.message}
`);
})
.catch((err) => {
throw err;
});
Instance methods
Promises
Engagespot notifications depends on a native ES6 Promise implementation. If your environment doesn't support ES6 Promises, you can polyfill.
TypeScript
Engagespot notifications includes TypeScript definitions out of the box.