Firebase Cloud Functions get data on real time database onCreate
问题 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(); exports.sendNotification = functions.database.ref('/messages/diyetisyen/{uname}/{msgid}/message') .onCreate((snapshot, context) => { let message = snapshot.val(); let uname = context.params.uname; let root = snapshot.ref.root; let token = root.child('/users/' + uname + '/token').ref.token; let payload = { data: { custom_notification: JSON.stringify({ body: message + '', title: