web-pushvapid

Web push notifications update VAPID keys


I previously used different push notification provider (they did not use VAPID keys) and got users subscribed to the service. Now, when I switched the push notification provider I'm in a situation where I kinda lost all previous subscribers, because they will not get the permission window again as they have already agreed to receive notifications. Is there a way to automatically update(re-subscribe?) the subscriber as he visits my webpage with a VAPID key pair so the "old" subscribers can still receive my push notifications?


Solution

  • Me again, I found that if you get the subscription with getSubscription() and then use the unsubscribe() function followed by another subscribe() function, you "update" the subscription and everything works without user interaction. The only real "issue" is that you can only update the subscription if the same user visits your page again.