What I am trying to create is a function that simply sends notification to topic
So everything I do is just sending a channel name and what I have is this
exports.sendNotification = functions.https.onRequest((req, res) => {
const dest = req.query.dest;
console.log(dest);
console.log('Message received');
const payLoad = {
notification:{
title: "Message title",
body: "You have a new message"
}
};
console.log("*** about to send message ");
admin.messaging().sendToTopic(dest, payLoad).then((response) => {
console.log("Successfully sent message ", response);
return res.send(JSON.stringify({"success":"true"}));
})
.catch((error) => {
console.log("Error sending message: ", error);
return res.send(JSON.stringify({"success":"false"}));
})
});
From the functions logs I have:
11:12:47.622 PM sendNotification Function execution started
11:12:47.704 PM sendNotification 9Td4I6aWOoVvNXWNE0pZYjwbXNv1
11:12:47.705 PM sendNotification Message received
11:12:47.720 PM sendNotification Function execution took 98 ms, finished with status: 'crash'
It seems that it's crashing when the payLoad is created, but I can't figure out why
Thank you