【发布时间】:2019-03-25 04:44:11
【问题描述】:
我正在创建一个这样的函数来向新用户发送通知。
exports.sendCreateSuccessNotification = functions.firestore
.document("users/{userId}")
.onCreate((snap, context) => {
const newVal = snap.data();
const payload = {
notification: {
title: "Create Account Success",
body: "Hello " + newVal.emailUser
}
};
admin.messaging().sendToDevice(newVal.notiToken, payload);
});
当我将代码更改为下面的返回时
exports.sendCreateSuccessNotification = functions.firestore
.document("users/{userId}")
.onCreate((snap, context) => {
const newVal = snap.data();
const payload = {
notification: {
title: "Create Account Success",
body: "Hello " + newVal.emailUser
}
};
return admin.messaging().sendToDevice(newVal.notiToken, payload);
});
【问题讨论】:
标签: node.js firebase firebase-cloud-messaging google-cloud-functions