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
EventTargetServiceWorkerRegistration
Properties
| Name | Description |
|---|---|
| Active | Gets the active worker, or null. |
| Cookies | Gets the cookie change subscriptions of the registration (https://cookiestore.spec.whatwg.org/#dom-serviceworkerregistration-cookies). |
| Installing | Gets the installing worker, or null. |
| NavigationPreload | Gets the navigation preload manager of the registration. |
| OnUpdateFound | Gets or sets the event handler of the updatefound event. |
| PaymentManager | Gets the payment handler of the registration. |
| Scope | Gets the serialized scope URL. |
| UpdateViaCache | Gets the update via cache mode. |
| Waiting | Gets the waiting worker, or null. |
Active
ServiceWorker.csCookies
ServiceWorker.csGets the cookie change subscriptions of the registration (https://cookiestore.spec.whatwg.org/#dom-serviceworkerregistration-cookies).
public CookieStoreManager Cookies { get; }Installing
ServiceWorker.csGets the installing worker, or null.
public ServiceWorker? Installing { get; }OnUpdateFound
ServiceWorker.csGets or sets the event handler of the updatefound event.
PaymentManager
PaymentHandler.csGets the payment handler of the registration.
public PaymentManager PaymentManager { get; }Scope
ServiceWorker.csUpdateViaCache
ServiceWorker.csGets the update via cache mode.
public ServiceWorkerUpdateViaCache UpdateViaCache { get; }Waiting
ServiceWorker.csMethods
| Name | Description |
|---|---|
| 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.csReturns 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
filterGetNotificationOptions?- The tag of the notifications to return (all the notifications when it is empty).
Returns
Task<IReadOnlyList<Notification>>
See also
ShowNotification(string, NotificationOptions?)
ServiceWorker.csShows 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
titlestring- The title of the notification.
optionsNotificationOptions?- 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.csUnregisters the registration (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-unregister).
Update()
ServiceWorker.csChecks whether the script of the service worker changed (https://w3c.github.io/ServiceWorker/#dom-serviceworkerregistration-update).
public Task<ServiceWorkerRegistration> Update()