【发布时间】:2021-05-25 11:59:05
【问题描述】:
我正在将 Cloud Functions 与 Cloud Messaging 结合使用,并且我想向所有具有特定 userRole 的设备发送通知(请参阅 userRoleList)。 不幸的是,我不知道该怎么做。 例如,我只想将 userRole "Aktive" 的 deviceTokens 推送到 deviceTokens。
到目前为止,这是我的 Cloud Functions 代码:
exports.sendNotificationAusschuss = functions.firestore.document('news/{newsId}').onCreate(async snapshot => {
const news = snapshot.data();
console.log('Message received');
//var deviceTokens = ??
const payload = {
notification:{
title: 'Message received',
body: `${news.newsText}`,
sound: "default"
}
};
return admin.messaging().sendToDevice(deviceTokens, payload);
});
非常感谢
【问题讨论】:
标签: node.js google-cloud-firestore google-cloud-functions firebase-cloud-messaging firebase-admin