1

I am trying to send a push notification to multiple users. On the first load of a page, I will subscribe the user for Push API and gets the EndPoint and storing that in Database for sending push notifications.

Do i need to continuously check for PushSubscription.Endpoint and update the database? Or it is fixed?

Nanju
  • 1,011
  • 1
  • 7
  • 9

1 Answers1

2

The endpoint can change, for example the subscription can expire (https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription/expirationTime).

You don't have to continuously check if it changes though, there's an event that is triggered when there is a change: https://developer.mozilla.org/en-US/docs/Web/Events/pushsubscriptionchange.

Also look at the related question about how to force triggering the event: How can I test pushsubscriptionchange event-handling code?.

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