0
我已經完成了身份驗證觸發器,它工作正常。如果有人刪除了他們的賬戶,我需要發送通知「這個用戶刪除了他的賬戶(電子郵件)」。這裏是我的代碼我試圖通過Firebase雲功能發出通知,但我的代碼沒有給出任何通知
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: "[email protected]"
}
};
admin.messaging().sendToDeveice(payload)
.then(function (response) {
console.log("Successfully sent message:", response);
})
.catch(function (error) {
console.log("Error sending message:", error);
})
}
我檢查了,但即時通訊無法將它們應用到我的塞納里奧u能幫助我與 – HemalHerath
我假設你想發送電子郵件給用戶, 看看這個例子: https://github.com/firebase/functions-samples/blob/master/quickstarts/email-users/functions/index。 js#L58 – Sichangi
不,我需要giv e推送通知給其他用戶使用我的應用程序「某人(電子郵件)刪除他的帳戶」,如 – HemalHerath