PushSubscription

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. Available only in secure contexts.

MDN Reference

Properties

Link copied to clipboard
open external val endpoint: String

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

Link copied to clipboard
open external val expirationTime: EpochTimeStamp?

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

Link copied to clipboard
open external val options: PushSubscriptionOptions

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

Functions

Link copied to clipboard
open external fun getKey(name: PushEncryptionKeyName): ArrayBuffer?

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.

Link copied to clipboard
open external fun toJSON(): PushSubscriptionJSON

The toJSON() method of the PushSubscription interface returns a JSON-serializable plain object representing the PushSubscription object.

Link copied to clipboard
inline suspend fun PushSubscription.unsubscribe(): Boolean

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

Link copied to clipboard
open external fun unsubscribeAsync(): Promise<JsBoolean>

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