notification

master
Bhaskar 1 year ago
parent 6811e2c38b
commit 75f2566533

@ -1307,6 +1307,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;

Loading…
Cancel
Save