Unable To Send Notifications Using Firebase Functions After Update
So Today I updated the firebase cli and after that deployed a new function. Although the firebase log shows that notifications has been sent to this many tokens, no notification oc
Solution 1:
You should return the promise (returned by token_send()
) in the sendNotificationCouncil
Cloud Function, as follows:
exports.sendNotificationCouncil = functions.database.ref(`path/Post/{pushId}`).onWrite((change,context) => {
const getDeviceTokensPromise = admin.database().ref(`/Token/token_no`).once('value');
const getBody=admin.database().ref(`/Post`).once('value');
var title_input='You have new Post';
var contentAlert = change.after.val();
var body_input=contentAlert.description; //showing error here
return token_send(admin,title_input,body_input,getBody,getDeviceTokensPromise,change);
});
Note that it is also a best practice to catch the errors in your Function and in this case return false
.
Post a Comment for "Unable To Send Notifications Using Firebase Functions After Update"