Web/API/PushSubscription/unsubscribe

From Get docs

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

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
unsubscribe() Chrome

Full support 42

Edge

Full support 16

Firefox Full support 44

Notes'

Full support 44

Notes'

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