我正在尝试通过 Firebase 云功能发出通知,但我的代码没有发出任何通知

I'm trying to give notification by Firebase cloud function, but my code doesn't give any notification

我已经完成身份验证触发器,它工作正常。如果有人删除了他们的帐户,我需要像那样发送通知 "this user deleted his account (email)"。这是我的代码

const functions = require('firebase-functions')

//initialize the app
const admin = require('firebase-admin')
admin.initializeApp(functions.config().firebase)

const ref = admin.database().ref()

//create user account function
exports.createUserAccount = functions.auth.user().onCreate(event => {
    const uid = event.data.uid
    const email = event.data.email

    const newUserRef = ref.child(`/UserNotify/${uid}`)
    return newUserRef.set({
        email: email
    })
})

//delete user account function
exports.cleanupUserData = functions.auth.user().onDelete(event => {
    const uid = event.data.uid
    const userRef = ref.child(`/UserNotify/${uid}`)
    return userRef.update({isDeleted: true}) 
})

function sendNotification() {

    console.log("Successfully sent");

    var payload = {
        notification: {
            title: "User get deleted",
            body: "sample@gmail.com"
        }
    };

    admin.messaging().sendToDeveice(payload)
        .then(function (response) {
            console.log("Successfully sent message:", response);
        })
        .catch(function (error) {
            console.log("Error sending message:", error);
        })
}

您可能输入有误 admin.messaging().sendToDevice() 而不是 sendToDeveice

检查:https://firebase.google.com/docs/cloud-messaging/admin/send-messages