2

I have implemented web push notifications using twilio. It works well on desktop and mobile phones.But, I am struggling to handle clicks on the notification on mobile. For desktop it works fine with the following code in the service worker

self.addEventListener('notificationclick', function(event) {
  event.notification.close();
  event.waitUntil(
   clients.openWindow('https://example.com')
  );
});

On mobile on clicking on the message nothing happens. I want to open a url in the browser when the user clicks on the message. Better if I can directly open the progressive web app.

Please suggest how to proceed.

Golak Sarangi
  • 809
  • 7
  • 22

1 Answers1

0

The code in the question is correct. The problem was with the domain. The domain name should be same as the domain of the pwa. Since I was testing it on dev environment, the domain did not match.

Golak Sarangi
  • 809
  • 7
  • 22