function unsubscribe() {
  var toggleButton = document.querySelector('.toggle-push-button');
  toggleButton.disabled = true;

  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    serviceWorkerRegistration.pushManager.getSubscription().then(
      function(pushSubscription) {
        if (!pushSubscription) {
          toggleButton.disabled = false;
          setPushDisabled();
          return;
        }

        pushSubscription.unsubscribe().then(function(successful) {
          toggleButton.disabled = false;
          setPushDisabled();
        }).catch(function(e) {
          console.log('Unsubscription error: ', e);
          setPushDisabled();
        });
      }).catch(function(e) {
        console.error('Error thrown while unsubscribing from push messaging.', e);
      });
  });
}
// Unsubscribes from the push service.
Unsubscribes from the push service.
Unsubscribes from the push service .
function unsubscribe() {
  var toggleButton = document.querySelector('.toggle-push-button');
  toggleButton.disabled = true;
  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    serviceWorkerRegistration.pushManager.getSubscription().then(
      function(pushSubscription) {
        if (!pushSubscription) {
          toggleButton.disabled = false;
          setPushDisabled();
          return;
        }
        pushSubscription.unsubscribe().then(function(successful) {
          toggleButton.disabled = false;
          setPushDisabled();
        }).catch(function(e) {
          console.log('Unsubscription error: ', e);
          setPushDisabled();
        });
      }).catch(function(e) {
        console.error('Error thrown while unsubscribing from push messaging.', e);
      });
  });
}
function unsubscribe ( ) { var toggleButton = document . querySelector ( '.toggle-push-button' ) ; toggleButton . disabled = true ; navigator . serviceWorker . ready . then ( function ( serviceWorkerRegistration ) { serviceWorkerRegistration . pushManager . getSubscription ( ) . then ( function ( pushSubscription ) { if ( ! pushSubscription ) { toggleButton . disabled = false ; setPushDisabled ( ) ; return ; } pushSubscription . unsubscribe ( ) . then ( function ( successful ) { toggleButton . disabled = false ; setPushDisabled ( ) ; } ) . catch ( function ( e ) { console . log ( 'Unsubscription error: ' , e ) ; setPushDisabled ( ) ; } ) ; } ) . catch ( function ( e ) { console . error ( 'Error thrown while unsubscribing from push messaging.' , e ) ; } ) ; } ) ; }
Unsubscribes from the push service.
Unsubscribes from the push service .