使用Firebase云功能推送通知

时间:2018-06-12 23:06:04

标签: javascript firebase firebase-cloud-messaging google-cloud-functions

我在Firebase数据库中有以下数据库结构

Database

我希望实现一个云功能,每次创建新节点时都会触发推送通知。此推送通知只应由属于创建新内容的UID的人员接收。

到目前为止,我得到了这个:

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

admin.initializeApp(functions.config().firebase);
exports.sendNewBestellung = functions.database.ref('/userBestellungen/{UID}').onWrite(event=>{

  const payload = {
    notification: {
        title: 'New Order!',
        body: 'New Order from (//Here I want to insert the content of the node Tischnummer)!',
        badge: '1',
        sound: 'default',
    }

  };

})

路径为/userBestellungen/(UID)/(orderID)/(some content),我想将推送消息仅发送到属于新创建内容的UID。

我是swift编程的新手,所以做一些java云函数我没有想法对我来说不容易我希望你能帮助我

0 个答案:

没有答案