【发布时间】:2018-12-04 08:40:23
【问题描述】:
我面临从我的 firebase 数据库中检索单个节点的两个数据值并在我的 javascript 文件中引用它但不知道如何去做的问题。我已经能够从节点(在本例中为“消息”)仅检索一个数据值,但我也想添加“来自”。大多数教程只引用一个,所以我真的很困惑。那么如何获取多个数据值呢? 这是我的代码...
JS 文件
exports.sendNotification7 = functions.database.ref('/GroupChat/{Modules}/SDevtChat/{SDevtChatId}/message')
.onWrite(( change,context) =>{
// Grab the current value of what was written to the Realtime Database.
var eventSnapshot = change.after.val();
var str = "New message from System Development Group Chat: " + eventSnapshot;
console.log(eventSnapshot);
var topic = "Management.Information.System";
var payload = {
data: {
name: str,
click_action: "Student_SystemsDevt"
}
};
// Send a message to devices subscribed to the provided topic.
return admin.messaging().sendToTopic(topic, payload)
.then(function (response) {
// See the MessagingTopicResponse reference documentation for the
// contents of response.
console.log("Successfully sent message:", response);
return;
})
.catch(function (error) {
console.log("Error sending message:", error);
});
});
【问题讨论】:
标签: javascript android firebase-realtime-database firebase-cloud-messaging google-cloud-functions