이 그래, 당신은 서버없이 중포 기지 이벤트를 통해 Google 클라우드 기능을 트리거 할 수 있습니다. 문서별로 Firebase는 사용자가 firebase 데이터베이스에 쓸 때 예를 들어 클라우드 기능을 사용하여 알림을 보낼 수 있습니다. 이를 위해
, 나는 그것을 확인합니다 멋진
'use strict';
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
exports.sendNotification = functions.database.ref('/articles/{articleId}')
.onWrite(event => {
// Grab the current value of what was written to the Realtime Database.
var eventSnapshot = event.data;
var str1 = "Author is ";
var str = str1.concat(eventSnapshot.child("author").val());
console.log(str);
var topic = "android";
var payload = {
data: {
title: eventSnapshot.child("title").val(),
author: eventSnapshot.child("author").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);
})
.catch(function (error) {
console.log("Error sending message:", error);
});
});
그래, 그게다고 생각해 .- 최근에 발표 한 게 틀림 없어? – MonkeyBonkey
@MonkeyBonkey 예 - 동영상이 어제 출신입니다. Google에서 대화를 포함하도록 답변을 업데이트했습니다. 다음 – bastien