The unsubscribe()
method of the PushSubscription
interface returns a Promise
that resolves to a boolean value when the current subscription is successfully unsubscribed.
The unsubscribe()
method of the PushSubscription
interface returns a Promise
that resolves to a boolean value when the current subscription is successfully unsubscribed.
js
unsubscribe()
None.
A Promise
that resolves to a boolean value when the current subscription is successfully unsubscribed.
js
navigator.serviceWorker.ready.then((reg) => { reg.pushManager.getSubscription().then((subscription) => { subscription .unsubscribe() .then((successful) => { // You've successfully unsubscribed }) .catch((e) => { // Unsubscribing failed }); }); });
Specification |
---|
Push API # dom-pushsubscription-unsubscribe |
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
unsubscribe |
42 | 17 | 44 | No | 29 | 16Supported on macOS 13 and later |
No | 50 | 48 | 37 | 16.4 | 5.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/PushSubscription/unsubscribe