Closed k2209 closed 1 year ago
const admin = require('firebase-admin') const fcm = require('fcm-notification') // For Notification const serviceAccount = require('../../firebase/push-notification-key.json') const certPath = admin.credential.cert(serviceAccount) //here goes my server key const FCM = new fcm(certPath, { legacyServerKey: config.FIREBASE_SERVER_KEY })) const Helper = {} Helper.pushNotification = async (notificationTitle, notificationBody, notificationData, fcm_token) => { try { let message = { notification: { title: notificationTitle, body: notificationBody }, data: {productId: notificationData}, token: fcm_token } FCM.send(message, (err) => { if (err) { return err } else { return err } }) } catch (err) { return err } } ``` this is my code