首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >TypeError:无法读取exports.sendNotification.functions.database.ref.onWrite.event上未定义的属性“子”

TypeError:无法读取exports.sendNotification.functions.database.ref.onWrite.event上未定义的属性“子”
EN

Stack Overflow用户
提问于 2018-06-25 05:01:27
回答 1查看 0关注 0票数 0

我试图向具有Firebase函数的FireBase数据库发送带有数据更新的通知。在函数执行之后,我将面临这些错误。

下面也是我的函数数据库快照。请仔细检查,看看是否有任何错误。

还有我的js密码。

代码语言:txt
复制
const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp(functions.config().firebase);

exports.sendNotification = functions.database.ref('/Lecture_Materials/{MIS}/{MISId}')
    .onWrite(event => {

    // Grab the current value of what was written to the Realtime Database.
    var eventSnapshot = event.data;
    var str1 = "Lecture note uploaded is: ";
    var str = str1.concat(eventSnapshot.child("name").val());
    console.log(str);

    var topic = "Management.Information.System";
    var payload = {
        data: {
            name: eventSnapshot.child("name").val(),
        }
    };

    // 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);
        });
    });
EN

回答 1

Stack Overflow用户

发布于 2018-06-25 14:13:09

1.0版本的SDK更改了数据库onW区事件的API。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100005508

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档