Reputation: 3437
I am trying to send a basic use-case of sending FCM message using Cloud Functions for Firebase. The function is timing out and the message never got send. Here is the function.
exports.sendNotification = functions.https.onRequest((req, res) => {
const keyword = req.query.keyword;
const username = req.query.username;
var payload = {
data: {
SearchKeyword: keyword,
user: username
}
};
const token = "real_fcm_token";
return admin.messaging().sendToDevice(token, payload);
});
How can I update the above code block to be able to send a data message to a device?
Upvotes: 1
Views: 439
Reputation: 38289
In addition to returning the Promise
from sendToDevice()
, you must also send HTTP status. For example:
res.status(200).send('Success');
const token = "real_fcm_token";
return admin.messaging().sendToDevice(token, payload);
Upvotes: 2