ServiceWorkerRegistration Class

A service worker registration (https://w3c.github.io/ServiceWorker/#serviceworkerregistration-interface), as seen by a window or a worker. Its ServiceWorkerRegistration.Installing, ServiceWorkerRegistration.Waiting and ServiceWorkerRegistration.Active workers are updated by tasks queued by the algorithms of the registration.

public sealed class ServiceWorkerRegistration : EventTarget
Inheritance
EventTarget ServiceWorkerRegistration

Properties

NameDescription
ActiveGets the active worker, or null.
CookiesGets the cookie change subscriptions of the registration (https://cookiestore.spec.whatwg.org/#dom-serviceworkerregistration-cookies).
InstallingGets the installing worker, or null.
NavigationPreloadGets the navigation preload manager of the registration.
OnUpdateFoundGets or sets the event handler of the updatefound event.
PaymentManagerGets the payment handler of the registration.
ScopeGets the serialized scope URL.
UpdateViaCacheGets the update via cache mode.
WaitingGets the waiting worker, or null.

Gets the active worker, or null.

public ServiceWorker? Active { get; }

Gets the cookie change subscriptions of the registration (https://cookiestore.spec.whatwg.org/#dom-serviceworkerregistration-cookies).

public CookieStoreManager Cookies { get; }

Gets the installing worker, or null.

public ServiceWorker? Installing { get; }

OnUpdateFound

ServiceWorker.cs

Gets or sets the event handler of the updatefound event.

public Action<Event>? OnUpdateFound { get; set; }

PaymentManager

PaymentHandler.cs

Gets the payment handler of the registration.

public PaymentManager PaymentManager { get; }

Gets the serialized scope URL.

public string Scope { get; }

UpdateViaCache

ServiceWorker.cs

Gets the waiting worker, or null.

public ServiceWorker? Waiting { get; }

Methods

NameDescription
GetNotifications(GetNotificationOptions?)Returns the persistent notifications of the registration that are shown (https://notifications.spec.whatwg.org/#dom-serviceworkerregistration-getnotifications), in creation order: new Notification objects that represent them.
ShowNotification(string, NotificationOptions?)Shows a persistent notification associated with the registration (https://notifications.spec.whatwg.org/#dom-serviceworkerregistration-shownotification), with BrowsingContextOptions.ShowNotification: the user activates or closes it by firing the notificationclick and notificationclose events at the active worker of the registration.
Unregister()Unregisters the registration (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-unregister).
Update()Checks whether the script of the service worker changed (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-update).

GetNotifications(GetNotificationOptions?)

ServiceWorker.cs

Returns the persistent notifications of the registration that are shown (https://notifications.spec.whatwg.org/#dom-serviceworkerregistration-getnotifications), in creation order: new Notification objects that represent them.

public Task<IReadOnlyList<Notification>> GetNotifications(GetNotificationOptions? filter = null)

Parameters

filter GetNotificationOptions?
The tag of the notifications to return (all the notifications when it is empty).

Returns

Task<IReadOnlyList<Notification>>

See also

ShowNotification(string, NotificationOptions?)

ServiceWorker.cs

Shows a persistent notification associated with the registration (https://notifications.spec.whatwg.org/#dom-serviceworkerregistration-shownotification), with BrowsingContextOptions.ShowNotification: the user activates or closes it by firing the notificationclick and notificationclose events at the active worker of the registration.

public Task ShowNotification(string title, NotificationOptions? options = null)

Parameters

title string
The title of the notification.
options NotificationOptions?
The options of the notification.

Returns

Task A task completed once the notification is shown, or failed with a TypeErrorException when the registration has no active worker, when the options are not valid, or when the notifications permission is not granted.

See also

Unregister()

ServiceWorker.cs

Unregisters the registration (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-unregister).

public Task<bool> Unregister()

Checks whether the script of the service worker changed (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-update).