【发布时间】:2019-02-04 04:41:48
【问题描述】:
我正在编写一个云函数,所以当添加新名称时,会触发通知。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.pushNotification = functions.database.ref('/name/{pushId}')
.onWrite(( change,context) => {
console.log('Push notification event triggered');
const payload = {
notification: {
title: 'App Name',
body: "New Vendor added",
sound: "default"
},
};
const options = {
priority: "high",
timeToLive: 60 * 60 * 24 //24 hours
};
return admin.messaging().sendToDevice("notifications", payload, options);
})
我需要对代码进行任何更改还是需要对 Android 应用进行更改? 功能将部署没有任何错误。但是当我向它添加数据时,云功能中没有日志或没有通知可以观察到。对 JS 比较陌生,非常感谢您的帮助。
【问题讨论】:
标签: javascript android firebase firebase-realtime-database google-cloud-functions