我正在尝试通过在Cloud Firestore数据库中触发的写入操作来在我的应用程序中实现抖动推送通知。当我在提供的路径中写入文档时,我在功能日志中看到此结果,并且在设备上未收到任何通知。注意我有一个未定义的函数
这是我的index.js代码
似乎找不到错在哪里
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firestore);
exports.pushNotification = functions.firestore.document('One/users/userdata/all_/current/JVN6Ty')
.onWrite(( change,context) => {
console.log("Push Notification event triggered");
var request =change.after.data();
var payload = {
notification:{
title:'Message Title Message from Cloud',
body:request.fcm_token,
badge:'1',
sound:'default'
}
};
return admin.messaging().sendToDevice(request.fcm_token, payload)
.then(function(response){
console.log("Successfully sent message: ",response);
console.log(response.results[0].error);
})
.catch(function(error){
console.log("Error sending message: ", error)
})
});