Задать вопрос
Ответы пользователя по тегу Веб-разработка
  • Сhrome notification не открывает сайт?

    IgorVader
    @IgorVader Автор вопроса
    в корне сайта есть файл firebase-messaging-sw.js
    данный файл вызывается когда приходит уведомление
    self.addEventListener('notificationclick', function(event) {
        console.log('On notification click: ', event.notification.tag);
        // Android doesn't close the notification when you click on it
        // See: http://crbug.com/463146
        event.notification.close();
    
        event.waitUntil(clients.matchAll({ type: 'window' }).then(clientsArr => {
            const hadWindowToFocus = clientsArr.some(windowClient => windowClient.url === event.notification.url ? (windowClient.focus(), true) : false);
            // Otherwise, open a new tab to the applicable URL and focus it.
            if (!hadWindowToFocus) clients.openWindow(event.notification.url ).then(windowClient => windowClient ? windowClient.focus() : null);
        }));
    });
    Ответ написан
    Комментировать