This is an experimental technologyCheck the Browser compatibility table carefully before using this in production.
The unsubscribe()
method of the PushSubscription
interface returns a Promise
that resolves to a Boolean
when the current subscription is successfully unsubscribed.
Syntax
​PushSubscription.unsubscribe().then(function(Boolean) { ... });
Parameters
None.
Returns
A Promise
that resolves to a Boolean
when the current subscription is successfully unsubscribed.
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 APIThe definition of 'unsubscribe()' in that specification. | Working Draft | Initial definition. |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
unsubscribe()
|
Chrome
Full support 42 |
Edge
Full support 16 |
Firefox Full support 44 Full support 44 Notes' Extended Support Releases (ESR) before Firefox 78 ESR do not support service workers and the Push API. |
IE
No support No |
Opera
Full support Yes |
Safari
No support No |
WebView Android
No support No |
Chrome Android
Full support 50 |
Firefox Android
Full support 48 |
Opera Android
Full support Yes |
Safari iOS
No support No |
Samsung Internet Android
Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support
- See implementation notes.'
- See implementation notes.
See also
PushSubscription.unsubscribe() by Mozilla Contributors is licensed under CC-BY-SA 2.5.