Сообщение возвращено как неопределенное - PullRequest
0 голосов
/ 07 июня 2018

Я пытался отправлять уведомления через функции firebase, когда данные хранятся в моей базе данных firebase.Он отправляет сообщение в порядке, но добавлен тег, который я добавил, чтобы увидеть, получило ли имя файла, который был загружен в мою базу данных firebase, возвращенное сообщение «Загруженная записка лекции: undefined ».Это строка 12 Я не понимаю, почему.Ниже мой код.

const functions = require('firebase-functions');
const admin = require('firebase-admin');

admin.initializeApp();

exports.sendNotification = functions.database.ref('/Lecture_Materials/{MIS}/{MISId}/name')
.onWrite(( change,context) =>{

// Grab the current value of what was written to the Realtime Database.
var eventSnapshot = change.after.val();
var str1 = "Lecture material uploaded is: " + eventSnapshot.name;
console.log(str1);

var topic = "Management.Information.System";
var payload = {
    data: {
        name: str1,
    }
};

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

Check out the functions LOGS interface please.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...