【发布时间】:2020-03-31 02:22:10
【问题描述】:
一旦在我的收藏“我的英雄学院”中创建了一个文档,我就会尝试向特定设备发送通知。当我尝试部署该功能时,我收到以下错误 -
Error: Error occurred while parsing your function triggers.
ReferenceError: chapter is not defined
代码:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
var msgData;
var token = "####";
exports.offerTrigger = functions.firestore.document(
'My Hero Academia'/{chapter}
).onCreate((snapshot,context) => {
msgData = snapshot.data();
var payload = {
"notifications": {
"title": "A new chapter has been released",
"body": "Read chapter " + msgData.number + " now!",
"sound": "default"
}
}
return admin.messaging().sendToDevice(token,payload).then((response) => {
console.log('Pushed notification');
}).catch((error) => {
console.log(error);
})
})
显然,我已经隐藏了我的令牌。正如错误所说,没有定义章节。但是 {chapter} 不是用来指代将要创建的新文档吗?
编辑:
{"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":13,"message":"INTERNAL"},"authenticationInfo":{"principalEmail":"user2312@gmail.com"},"requestMetadata":{"requestAttributes":{},"destinationAttributes":{}},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"projects/dmscraper-c91da/locations/us-central1/functions/offerTrigger"}
【问题讨论】:
标签: firebase google-cloud-functions