The getRegistration()
method of the ServiceWorkerContainer
interface gets a ServiceWorkerRegistration
object whose scope URL matches the provided client URL. The method returns a Promise
that resolves to a ServiceWorkerRegistration
or undefined
.
getRegistration()
getRegistration(clientURL)
A Promise
that resolves to a ServiceWorkerRegistration
object or undefined
.
navigator.serviceWorker.getRegistration("/app").then((registration) => {
if (registration) {
document.querySelector("#status").textContent =
"ServiceWorkerRegistration found.";
}
});