'How to detect change and unregister in service workers

I have a react app using service workers for push notifications. When I'm testing i sometimes update and unregister the service worker. Today I noticed that as I'm doing this the old service workers no longer work.

I saw there is an event (pushsubscriptionchange) which should let you call an action after the service worker changes. I tested 4 hours now and it never seems to trigger. Is it outdated or is there a better way?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source