Clients Class

The clients of a service worker (https://w3c.github.io/ServiceWorker/#clients-interface): the windows and the workers of its origin, in the browsing context group of the service worker.

public sealed class Clients

Methods

NameDescription
Claim()Makes the service worker the controller of the clients whose URL matches its registration (https://w3c.github.io/ServiceWorker/#clients-claim).
Get(string)Returns the client whose id is id, or null (https://w3c.github.io/ServiceWorker/#clients-get).
MatchAll(ClientQueryOptions?)Returns the clients of the service worker (https://w3c.github.io/ServiceWorker/#clients-matchall).
OpenWindow(string)Opens a new top-level browsing context, navigated to url (https://w3c.github.io/ServiceWorker/#clients-openwindow): returns its window client, or null when its document does not have the origin of the service worker.

Claim()

Clients.cs

Makes the service worker the controller of the clients whose URL matches its registration (https://w3c.github.io/ServiceWorker/#clients-claim).

public Task Claim()

Returns

Task

Exceptions

DomException
An InvalidStateError when the service worker is not the active worker of its registration.

See also

Get(string)

Clients.cs

Returns the client whose id is id, or null (https://w3c.github.io/ServiceWorker/#clients-get).

public Task<Client?> Get(string id)

MatchAll(ClientQueryOptions?)

Clients.cs

Returns the clients of the service worker (https://w3c.github.io/ServiceWorker/#clients-matchall).

public Task<IReadOnlyList<Client>> MatchAll(ClientQueryOptions? options = null)

OpenWindow(string)

Clients.cs

Opens a new top-level browsing context, navigated to url (https://w3c.github.io/ServiceWorker/#clients-openwindow): returns its window client, or null when its document does not have the origin of the service worker.

public Task<WindowClient?> OpenWindow(string url)

Parameters

url string

Returns

Task<WindowClient?>

Remarks

A window of the origin must have the transient activation (e.g. the user clicked it).

See also