diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 07d9023d..1bf5364c 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -1309,6 +1309,33 @@ admin.initializeApp({ credential: admin.credential.cert(serviceAccount), }); +const sendPushNotification = async (registrationToken, title, body) => { + const message = { + notification: { + title: title, + body: body, + }, + data: { + title: title, + body: body, + }, + }; + + const options = { + priority: "high", + timeToLive: 60 * 60 * 24, + }; + + try { + const response = await admin.messaging().sendToDevice(registrationToken, message, options); + console.log('FCM response:', response); // Log the FCM response + return response; // Return the FCM response object + } catch (error) { + console.error('FCM error:', error); + throw error; // Throw the error to handle it further up the call stack + } +}; + exports.motorAction = async (req, reply) => { try { const customerId = req.params.customerId;