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.
PushSubscription.endpoint Read only
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
PushSubscription.subscriptionId Read only
DOMString containing the subscription ID associated with the push subscription.PushSubscription.getKey()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()PushSubscription.unsubscribe()Promise that resolves to a Boolean when the current subscription is successfully unregistered.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
})
})
}); | Specification | Status | Comment |
|---|---|---|
| Push API The definition of 'PushSubscription' in that specification. | Working Draft | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | 42 | Yes | 44
|
No | 29 | No |
endpoint
|
42 | 16 | 44
|
No | 29 | No |
expirationTime
|
60 | 16 | ? | No | 47 | No |
options
|
42 | 16 | 44
|
No | 29 | No |
subscriptionId
|
42 | Yes | 44
|
No | 29 | No |
getKey
|
42 | 16 | 44
|
No | 29 | No |
toJSON
|
42 | ? | ? | No | ? | ? |
unsubscribe
|
42 | 16 | ? | No | ? | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | No | 42 | ? | 48 | 29 | No | 4.0 |
endpoint
|
No | 42 | ? | 48 | 29 | No | 4.0 |
expirationTime
|
No | 60 | ? | ? | 47 | No | No |
options
|
No | 42 | ? | 48 | 29 | No | 4.0 |
subscriptionId
|
No | 42 | ? | 48 | 29 | No | 4.0 |
getKey
|
No | 42 | ? | 48 | 29 | No | 4.0 |
toJSON
|
No | 50 | ? | ? | ? | ? | 5.0 |
unsubscribe
|
No | 50 | ? | ? | ? | ? | 5.0 |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription