Onze vrijwilligers hebben dit artikel nog niet naar het Nederlands vertaald. Doe mee en help de klus te klaren!
U kunt het artikel ook in het English (US) lezen.

This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

 

The PushSubscription interface of the Push API provides a subcription's URL endpoint and allows unsubscription from a push service.

An instance of this interface can be serialized.

Properties

PushSubscription.endpoint Read only
A USVString containing the endpoint associated with the push subscription.
PushSubscription.expirationTime Read only
DOMHighResTimeStamp of the subscription expiration time associated with the push subscription, if there is one, or null otherwise. 
PushSubscription.options Read only
An object containing the options used to create the subscription.
PushSubscription.subscriptionId Read only
A DOMString containing the subscription ID associated with the push subscription.

Methods

PushSubscription.getKey()
Returns an ArrayBuffer which contains the client's public key, which can then be sent to a server and used in encrypting push message data.
PushSubscription.toJSON()
Standard serializer — returns a JSON representation of the subscription properties.
PushSubscription.unsubscribe()
Starts the asynchronous process of unsubscribing from the push service, returning a Promise that resolves to a Boolean when the current subscription is successfully unregistered.

Example

navigator.serviceWorker.ready.then(function(reg) {
  reg.pushManager.getSubscription().then(function(subscription) {
    subscription.unsubscribe().then(function(successful) {
      // You've successfully unsubscribed
    }).catch(function(e) {
      // Unsubscription failed
    })
  })        
});

Specifications

Specification Status Comment
Push API
The definition of 'PushSubscription' in that specification.
Working Draft Initial definition

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
PushSubscriptionChrome Full support 42Edge Full support YesFirefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
IE No support NoOpera Full support 29Safari No support NoWebView Android No support NoChrome Android Full support 42Firefox Android Full support 48Opera Android Full support 29Safari iOS No support NoSamsung Internet Android Full support 4.0
endpointChrome Full support 42Edge Full support 16Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
IE No support NoOpera Full support 29Safari No support NoWebView Android No support NoChrome Android Full support 42Firefox Android Full support 48Opera Android Full support 29Safari iOS No support NoSamsung Internet Android Full support 4.0
expirationTimeChrome Full support 60Edge Full support 16Firefox No support NoIE No support NoOpera Full support 47Safari No support NoWebView Android No support NoChrome Android Full support 60Firefox Android No support NoOpera Android Full support 44Safari iOS No support NoSamsung Internet Android No support No
optionsChrome Full support 42Edge Full support 16Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
IE No support NoOpera Full support 29Safari No support NoWebView Android No support NoChrome Android Full support 42Firefox Android Full support 48Opera Android Full support 29Safari iOS No support NoSamsung Internet Android Full support 4.0
subscriptionIdChrome Full support 42Edge Full support YesFirefox No support NoIE No support NoOpera Full support 29Safari No support NoWebView Android No support NoChrome Android Full support 42Firefox Android No support NoOpera Android Full support 29Safari iOS No support NoSamsung Internet Android Full support 4.0
getKey()Chrome Full support 42Edge Full support 16Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
IE No support NoOpera Full support 29Safari No support NoWebView Android No support NoChrome Android Full support 42Firefox Android Full support 48Opera Android Full support 29Safari iOS No support NoSamsung Internet Android Full support 4.0
toJSON()Chrome Full support 42Edge Full support 17Firefox Full support 46IE No support NoOpera Full support YesSafari No support NoWebView Android No support NoChrome Android Full support 50Firefox Android Full support 48Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 5.0
unsubscribe()Chrome Full support 42Edge Full support 16Firefox Full support 44
Notes
Full support 44
Notes
Notes Service workers (and Push) have been disabled in the Firefox 45 & 52 Extended Support Releases (ESR).
IE No support NoOpera Full support YesSafari No support NoWebView Android No support NoChrome Android Full support 50Firefox Android Full support 48Opera Android Full support YesSafari iOS No support NoSamsung Internet Android Full support 5.0

Legend

Full support  
Full support
No support  
No support
See implementation notes.
See implementation notes.

See also

Documentlabels en -medewerkers

Laatst bijgewerkt door: mdnwebdocs-bot,