Нажмите действие не работает в уведомлении PWA - PullRequest
1 голос
/ 06 марта 2020

Я работаю pwa, где уведомления приходят нормально. Но когда я нажимаю на уведомление, ничего не происходит. Я знаю этот вопрос уже задавали. Мой код ниже: -

firebase.initializeApp({
   'messagingSenderId': 'SEnder_id'
});

  // 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);
     // Customize notification here
     const notificationTitle = 'Background Message Title';
     const notificationOptions = {
     body: 'Background Message body.',
     icon: '/itwonders-web-logo.png',
    data: {
        click_action: payload.notification.click_action
    }
  };
  // Notifcation click event
        self.addEventListener('notificationclick', function (event) {
        event.notification.close();
       clients.openWindow("https://youtu.be/PAvHeRGZ_lA"); //even simple static link not opening
   });
   return self.registration.showNotification(notificationTitle,
        notificationOptions);
});

Я также получаю значение click_action при получении уведомления.

...