How to get old subscription data when using pushsubscriptionchange

I am saving subscription endpoint, auth and p256dh keys in a db, and I wanted to implement pushsubscriptionchange event on my service worker to resubscribe and update the old subscription I have in the db when it expires, but I can't find a way to get the old subscription data. I am using this simple code to test it.

self.addEventListener('pushsubscriptionchange', function(event) {
    console.log('subscription expired');
        self.registration.pushManager.subscribe({ userVisibleOnly: true })
        .then(function(subscription) {
            console.log('subscribed again');
            // send subscription data to server to update database

To trigger the event in firefox I remove the permissions and grant them again, the event fires fine but I can't find any information that would let me know the old subscription data so I can delete/update it on the db, so I will end up with expired subscriptions plus the new ones.

How can I get the old subscription data?

Forgot to add, I have no other way to identify the user, they are not registered and it's not an app, just a website.


  • You can't. Any browser pass params in the pushsubscriptionchange currently.

    For more details see this: How to handle WebPush API PushSubscriptionChange event in modern browsers