성공적으로 Firebase 용 클라우드 기능에서 실행되도록 여러 푸시 알림을 시도합니다.Firebase 용 클라우드 기능이 여러 사용자에게 푸시됩니다.
나는
- message_receipts
- -KtvyTN3nbVKoFjHdpJg
- hHhs5Aco38X1W8EhaaxrwsQDXwy1 노드 내 메시지 영수증을 저장 : "영수증"
- nI25FjUnBfQiCWzdCUIAe8CWTPQ2 : "영수증"
클라우드 기능에 나는 다음과 같은 시도 푸시 알림을 보내려면 내가 할 모든 전송 한 통지
//*********************************************************************************************************** */
//handle lsit item added by shared user
if (String(msgData.messageType) == 'ListItemAddedBySharedUser') {
return admin.database().ref("message_receipts").child(event.params.messageID).once('value').then(receipts => {
receipts.forEach(function (receipt) {
//Send push to receipt
return admin.database().ref('/users/' + receipt.key).once('value').then(usnap => {
//Send push to users fcmToken
const userSnap = usnap.val()
console.log('sending Push to ' + userSnap.fcmToken)
//create Notification Payload
var payload = {
notification: {
title: msgData.title,
body: msgData.message,
badge: '1',
sound: 'default',
sbID: String(event.data.key),
senderID: msgData.senderID,
listID: msgData.listID,
receiptID: receipt.key,
notificationType: String(msgData.messageType),
}
};
return admin.messaging().sendToDevice(userSnap.fcmToken, payload).then(response => {
console.log("Successfully sent invite message:", response)
console.log(response.results[0].error)
}).catch((err) => { console.log("Error sending Push", err) })
})
})
})
} //*********************************************************************************************************** */
입니다. 자바 스크립트와 클라우드 기능에 새로운 것이 있습니다. 모든 사용자에게 알림을 받으려면 어떻게해야합니까?
안녕하세요, 완성 된 솔루션을 게시 하시겠습니까? 그것을보고 싶어 할 것입니다. – Gugulethu