I couldn't run the function why? my goal is to send token to this function ,but I can't get into the function.
there is no output in firebase function console (console.log("Is it Working ? ") console.log("ReqBody : "+req)
where am i doing wrong ?
exports.sendNotifications = functions.https.onRequest((req, res) => {
if (req.method !== 'POST') {
return res.status(500).json({ message: 'Not allowed.' });
}
console.log("Is it Working ? ")
console.log("ReqBody : "+req)
var message = {
notification: {
title: 'New Message',
body: 'New Message!'
},
token: req.body.token
};
admin.messaging().send(message)
.then((response) => {
console.log('Successfully sent message:', response);
})
.catch((error) => {
console.log('Error sending message:', error);
});
});
send message method
sendMessage(){
let body = {
token : "token_string"
}
this.http.post(
'https://us-central1-project.cloudfunctions.net/sendNotifications',
body
);
}