var config = {
messagingSenderId: "18????????2"
};
firebase.initializeApp(config);
const messaging = firebase.messaging();
messaging.setBackgroundMessageHandler(function (payload) {
$.ajax({
type: "POST",
dataType: "json",
data: { notificationID: payload.data.notificationID },
url: "https://myapi/somerestservice",
success: function (data) {
console.log("remove notification status : " + data.Status + " - Message : " + data.Message);
}
});
const notificationTitle = payload.notification.title;
const notificationOptions = {
body:payload.notification.body,
};
return self.registration.showNotification(notificationTitle, notificationOptions);
我收到的背景信息沒有任何錯誤和消息代碼將出現在瀏覽器中完美FCM serviceworker收到背景消息,但不執行
我的問題是我需要execute
一些代碼從db
刪除數據,但任何代碼我在setBackgroundMessageHandler
添加時接收到消息 沒有被解僱是有當背景 收到消息的任何觸發的事件(在前臺我用onMessage
及其工作不錯)