pushkit
Version:
Everything you need to enable Web Push Notification in your Node.JS web application. Uses the browser's delivery channel to send push notification(Free of cost), which means no extra third-party service (except for the browser's own delivery channel). Wor
18 lines (17 loc) • 532 B
JavaScript
/// <reference types="./server" />
const webPush = require("web-push");
/**
* @type {import('./server')}
*/
module.exports = function createSender({publicKey,privateKey},email){
webPush.setVapidDetails(`mailto:${email}`, publicKey, privateKey);
let sender = {webPush}
sender.send = function(subscription, title = "PusKit", config = {}){
let message = {
title,
config
}
return webPush.sendNotification(subscription, JSON.stringify(message));
}
return sender;
}