This is what my log looks like when my push notification gets called on중포 기지 클라우드 메시징 푸시 알림되지는 장치
나는 현재 아이폰에 대한 사용자 설정에 사용자에 대해 설정 푸시 알림을 만드는 작업입니다로 전송된다. 현재 Firebase를 사용하고 있으므로 당연히 Firebase Cloud Messaging을 사용하여이 작업을 완료했습니다. 이것은 내 Firebase에 배포 할 기능의 설정입니다. 여기에 잘못된 내용이있어 알림이 장치로 전송되지 않습니다. 어떤 도움을 주셔서 감사 드리며 더 이상 필요한 정보가 있으면 제공해 드릴 수 있습니다.
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);
// Listens for new messages added to messages/:pushId
exports.pushNotification = functions.database.ref('/messages/{pushId}').onWrite(event => {
console.log('Push notification event triggered');
// Grab the current value of what was written to the Realtime Database.
var valueObject = event.data.val();
console.log(valueObject)
if(valueObject.photoUrl != null) {
valueObject.photoUrl= "Sent you a photo!";
}
// Create a notification
const payload = {
notification: {
title:valueObject.toId,
body: valueObject.text || valueObject.photoUrl,
sound: "default"
},
};
//Create an options object that contains the time to live for the notification and the priority
const options = {
priority: "high",
timeToLive: 60 * 60 * 24
};
return admin.messaging().sendToTopic("pushNotifications", payload, options);
if(!data.changed()){
});
exports.pushNotification = functions.database.ref('/messages/{pushId}').onWrite(event => {
const data = event.data;
console.log('Push notification event triggered');
return;
}
});
firebase cloud messaging 섹션에 p12를 업로드 했습니까? –
안녕하세요, 답장을 보내 주셔서 감사합니다! 나는 p12가 뭔지 잘 모르겠다. @JigneshMayani – oneQuestionAsker
응답에 오류가 있습니까? –