Ravikrn
Ravikrn

Reputation: 397

Service worker events related to web push notifications

In web push notifications documentation, I see that service worker can get triggered by few events like push, notificationclick. For tracking CTR, notificationclick event is very important. Similarly, is there any event like 'rejectnotification' that gets triggered when user rejects notification. So, service worker can track users rejecting notifications.

Upvotes: 4

Views: 336

Answers (3)

collimarco
collimarco

Reputation: 35470

There is a notificationclose event as described here:

https://developers.google.com/web/updates/2016/03/notifications?hl=en

Upvotes: 0

Marco Castelluccio
Marco Castelluccio

Reputation: 10802

There is a notificationclose event, but only for persistent notifications.

https://notifications.spec.whatwg.org/#closing-a-notification

Upvotes: 2

Miguel Garcia
Miguel Garcia

Reputation: 1029

I assume that by rejected you mean close? If so there is no such event. There used to be an onclose event but is now deprecated.

https://developer.mozilla.org/en-US/docs/Web/API/Notification/onclose

Upvotes: 4

Related Questions