Table of Contents

Class PushSubscription

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The PushSubscription interface of the Push API provides a subscription's URL endpoint along with the public key and secrets that should be used for encrypting push messages to this subscription.
This information must be passed to the application server, using any desired application-specific method.

[Value("PushSubscription")]
public class PushSubscription
Inheritance
PushSubscription
Inherited Members

Remarks

The interface also provides information about when the subscription will expire, and a method to unsubscribe from the subscription.

-Push API
-Service Worker API

See also on MDN

Constructors

PushSubscription()

public PushSubscription()

Properties

Endpoint

The endpoint read-only property of the
PushSubscription interface returns a string containing
the endpoint associated with the push subscription.

[Value("endpoint")]
public string Endpoint { get; }

Property Value

string

A string.

Remarks

The endpoint takes the form of a custom URL pointing to a push server, which can be
used to send a push message to the particular service worker instance that subscribed to
the push service. For this reason, it is a good idea to keep your endpoint a secret, so
others do not hijack it and abuse the push functionality.

See also on MDN

ExpirationTime

The expirationTime read-only property of the
PushSubscription interface returns a Number
of the subscription expiration time associated with the push subscription, if there is
one, or null otherwise.

[Value("expirationTime")]
public ulong? ExpirationTime { get; }

Property Value

ulong?

A Number or null.

Remarks

Options

The options read-only property
of the PushSubscription interface is an object containing the options
used to create the subscription.

[Value("options")]
public PushSubscriptionOptions Options { get; }

Property Value

PushSubscriptionOptions

An read-only PushSubscriptionOptions object containing the following values:

Remarks

Methods

GetKey(PushEncryptionKeyName)

The getKey() method of the PushSubscription interface
returns an ArrayBuffer representing a client public key, which can then
be sent to a server and used in encrypting push message data.

[Value("getKey")]
public ArrayBuffer? GetKey(PushEncryptionKeyName name)

Parameters

name PushEncryptionKeyName

Returns

ArrayBuffer

An ArrayBuffer or null if no public key can be found.

Remarks

ToJSON()

The toJSON() method of the PushSubscription interface is a
standard serializer: it returns a JSON representation of the subscription properties,
providing a useful shortcut.

[Value("toJSON")]
public PushSubscriptionJSON ToJSON()

Returns

PushSubscriptionJSON

A JSON object. It contains the subscription endpoint, expirationTime and public keys, as an
endpoint member, an expirationTime member and a keys member.

Remarks

Unsubscribe()

The unsubscribe() method of the PushSubscription interface
returns a Promise that resolves to a boolean value when the
current subscription is successfully unsubscribed.

[Value("unsubscribe")]
public Task<bool> Unsubscribe()

Returns

Task<bool>

A Promise that resolves to a boolean value when the current
subscription is successfully unsubscribed.

Remarks