importScripts ('https://www.gstatic.com/firebasejs/6.3.4/firebase-app.js'); importScripts (' https://www.gstatic.com/firebasejs/6.3.4/firebase-messaging.js');
firebase.initializeApp({
apiKey: "xxxxxxxxxxxx",
authDomain: "xxxxxxxxxxxx",
databaseURL: "https://xxxxxxxxxxxx",
projectId: "xxxxxxxxxxxx",
storageBucket: "",
messagingSenderId: "xxxxxxxxxxxx",
appId: "xxxxxxxxxxxx"
})
/*
Retrieve an instance of Firebase Messaging so that it can handle background messages.
*/
const messaging = firebase.messaging()
messaging.setBackgroundMessageHandler(function (payload) {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
const notification = JSON.parse(payload.data.notification);
// Customize notification here
const notificationTitle = notification.title;
const notificationOptions = {
body: notification.body,
icon: notification.icon
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
Полезная нагрузка:
{
"data":{
"notification": {
"title": "Firebase",
"body": "test",
"click_action": "http://xxxxx",
"icon": "icon.png"
}}
,
"to": "/topics/all"
}
при выполнении отладчика, данные полезной нагрузки поступают в метод setBackgroundMessageHandler,при достижении self.registration.showNotification не отображается окно всплывающего сообщения и консоль не помечает ошибку, версия рабочего стола chrome 77.0.3865.90 (сборка официальная) (64 бита) В mozilla, если отображается всплывающее сообщение
что может происходить?
Можно ли разместить диспетчер тегов Google для захвата щелчков во всплывающем окне? Для фонового процесса
с уважением