PushSubscription.unsubscribe()

Experimental: This is an experimental technology
Check 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 value when the current subscription is successfully unsubscribed.

Syntax

PushSubscription.unsubscribe().then(function(Boolean) { /* ... */ });

Parameters

None.

Returns

A Promise that resolves to a boolean value 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) {
      // Unsubscribing failed
    })
  })
});

Specifications

Specification
Push API
# dom-pushsubscription-unsubscribe

Browser compatibility

BCD tables only load in the browser

See also