JP _
JP _

Reputation: 570

How to check if service worker is installed and active (using Workbox)?

The Worbox activated event is one way but I'd like to know outside of this event.

Is there some kind of function/method I could call on-demand to check if the registered service worker is installed/active? Like isServiceWorkerActive() or something like that?

I can only think of navigator.serviceWorker.controller.state == 'activated', is that the proper way of achieving this?

Upvotes: 0

Views: 1826

Answers (1)

Joshua West
Joshua West

Reputation: 1

I'm not sure if this helps, but you can check it easily in Chrome using the DevTools. Click on the Application tab and make sure you have Service Workers selected in the sidebar. If it's installed, it should show the current service worker along with pertinent information and options such as update and unregister.

Upvotes: -2

Related Questions