The ServiceWorkerRegistration interface of the ServiceWorker API represents the service worker registration. You register a service worker to control one or more pages that share the same origin.

Documentation ServiceWorkerRegistration by Mozilla Contributors, licensed under CC-BY-SA 2.5.

See also:

Variables

read onlyactive:ServiceWorker

Returns a service worker whose state is either activating or activated. This is initially set to null. An active worker will control a ServiceWorkerClient if the client's URL falls within the scope of the registration (the scope option set when ServiceWorkerContainer.register is first called.)

read onlyinstalling:ServiceWorker

Returns a service worker whose state is installing. This is initially set to null.

onupdatefound:Function

An EventListener property called whenever an event of type updatefound is fired; it is fired any time the ServiceWorkerRegistration.installing property acquires a new service worker.

read onlypushManager:PushManager

Returns a reference to the PushManager interface for managing push subscriptions including subscribing, getting an active subscription, and accessing push permission status.

read onlyscope:String

Returns a unique identifier for a service worker registration. This must be on the same origin as the document that registers the ServiceWorker.

read onlywaiting:ServiceWorker

Returns a service worker whose state is waiting. This is initially set to null.

Methods

getNotifications(?filter:Null<GetNotificationOptions>):Promise<Array<Notification>>

Returns a Promise that resolves to an array of Notification objects.

Throws:

null

DOMError

showNotification(title:String, ?options:Null<NotificationOptions>):Promise<Void>

Displays the notification with the requested title.

Throws:

null

DOMError

unregister():Promise<Bool>

Unregisters the service worker registration and returns a Promise. The service worker will finish any ongoing operations before it is unregistered.

Throws:

null

DOMError

update():Promise<Void>

Checks the server for an updated version of the service worker without consulting caches.

Throws:

null

DOMError

Inherited Variables

Inherited Methods

Defined by EventTarget

addEventListener(type:String, listener:Function, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

addEventListener(type:String, listener:EventListener, ?options:EitherType<AddEventListenerOptions, Bool>, ?wantsUntrusted:Bool):Void

Register an event handler of a specific event type on the EventTarget.

Throws:

null

DOMError

dispatchEvent(event:Event):Bool

Dispatch an event to this EventTarget.

Throws:

null

DOMError

removeEventListener(type:String, listener:Function, ?options:EitherType<EventListenerOptions, Bool>):Void

removeEventListener(type:String, listener:EventListener, ?options:EitherType<EventListenerOptions, Bool>):Void

Removes an event listener from the EventTarget.

Throws:

null

DOMError