在我的收藏集“我的英雄学院”中创建文档后,我正尝试发送通知。因此,我修改了一些代码,但是当我尝试部署它时,却出现了错误。
Error: Functions did not deploy properly.
代码:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
//const db = admin.firestore();
const fcm = admin.messaging();
export const sendToTopic = functions.firestore
.document('My Hero Academia/{chapterid}')
.onCreate(async snapshot => {
const chapter = snapshot.data();
const payload: admin.messaging.MessagingPayload = {
notification: {
title: 'A new chapter is out',
body: `Read Boku no Hero Academia Chapter ${chapter.number} now`,
clickAction: 'FLUTTER_NOTIFICATION_CLICK'
}
};
return fcm.sendToTopic('My Hero Academia', payload);
});
我到底在做什么错?