UNPKG

notification-services

Version:

Use email, sms and custom notification services for node.js application easily

29 lines (28 loc) 981 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.customNotification = void 0; const axios_1 = __importDefault(require("axios")); const customNotification = (options, callback) => { const { title, text, fcm_tokens, serverKey } = options; const notification_body = { 'notification': { 'title': { title }, 'text': { text } }, 'registration_ids': fcm_tokens }; axios_1.default.post('https://fcm.googleapis.com/fcm/send', { notification_body }, { headers: { 'Content-type': 'application/json', 'Authorization': `key=${serverKey}` } }).then(response => { callback(response, null); }).catch(error => { callback(null, error); }); }; exports.customNotification = customNotification;