4

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.

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Ravikrn
  • 387
  • 1
  • 3
  • 19

3 Answers3

4

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

Miguel Garcia
  • 1,029
  • 5
  • 14
2

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

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

Marco Castelluccio
  • 10,152
  • 2
  • 33
  • 48
0

There is a notificationclose event as described here:

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

collimarco
  • 34,231
  • 36
  • 108
  • 142