push-notificationservice-workeraddeventlistenerweb-pushservice-worker-events

Open webpush notification url in a popup window


I am using Django-Webpush to send push notifications to users, where clicking on the notifications it opens the URL in a new tab.

What I want to do is to open the URL in a new popup window similar to:

window.open(href,'height=500,width=800,resizable=yes,scrollbars=yes');

I have searched and I cannot find a way to do this with self.clients.openWindow(). It simply opens the URL in a new tab, which is not useful to me.

Is there a way or an alternative to use in the notification event listener?

self.addEventListener('notificationclick', function(event){
 event.waitUntil(
   event.preventDefault(),
   event.notification.close(),
   self.clients.openWindow(event.notification.data.url)
   );
});

Solution

  • After a deep research on the matter, I discovered there is currently (December 2020) no way for the openWindow() to open the notification link in a new window. It will always force the url to open in a new tab.