Реагирует Js firebase не будет доставлять уведомление на открытое окно addListener ('messagesclick')
У меня возникает проблема, когда у меня нет открытых клиентов / windows, и я щелкните по уведомлению, откроется URL, но оно не доставит уведомление.
onMessage и eventListener для "message" в фоновом режиме в моем компоненте ничего не получают, когда происходит событие openWindow.
messaging.setBackgroundMessageHandler((payload) => {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = payload.title;
const notificationOptions = {
body: payload.body,
icon: '/icon.png'
};
return self.registration.showNotification(notificationTitle,
notificationOptions);
});
self.addEventListener('notificationclick', (event) => {
const clickedNotification = event.notification;
clickedNotification.close();
const promiseChain = clients
.matchAll({
type: 'window',
includeUncontrolled: true
})
.then(windowClients => {
let matchingClient = null;
for (let i = 0; i < windowClients.length; i++) {
const windowClient = windowClients[i];
if (windowClient.url === feClickAction) {
matchingClient = windowClient;
break;
}
}
if (matchingClient) {
return matchingClient.focus();
} else {
return clients.openWindow(feClickAction);
}
});
event.waitUntil(promiseChain);
});