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

  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true}).then(function(s) {
        setPushEnabled();
        toggleButton.disabled = false;
        subscription = s
      }).catch(function(e) {
        if (Notification.permission === 'denied') {
          console.warn('Permission for Notifications was denied');
          toggleButton.disabled = true;
        } else {
          console.error('Unable to subscribe to push.', e);
          toggleButton.disabled = false;
          setPushDisabled();
        }
      });
  });
}
// Subscribes to the push service.
Subscribes to the push service.
Subscribes to the push service .
function subscribe() {
  var toggleButton = document.querySelector('.toggle-push-button');
  toggleButton.disabled = true;
  navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
    serviceWorkerRegistration.pushManager.subscribe({userVisibleOnly: true}).then(function(s) {
        setPushEnabled();
        toggleButton.disabled = false;
        subscription = s
      }).catch(function(e) {
        if (Notification.permission === 'denied') {
          console.warn('Permission for Notifications was denied');
          toggleButton.disabled = true;
        } else {
          console.error('Unable to subscribe to push.', e);
          toggleButton.disabled = false;
          setPushDisabled();
        }
      });
  });
}
function subscribe ( ) { var toggleButton = document . querySelector ( '.toggle-push-button' ) ; toggleButton . disabled = true ; navigator . serviceWorker . ready . then ( function ( serviceWorkerRegistration ) { serviceWorkerRegistration . pushManager . subscribe ( { userVisibleOnly : true } ) . then ( function ( s ) { setPushEnabled ( ) ; toggleButton . disabled = false ; subscription = s } ) . catch ( function ( e ) { if ( Notification . permission === 'denied' ) { console . warn ( 'Permission for Notifications was denied' ) ; toggleButton . disabled = true ; } else { console . error ( 'Unable to subscribe to push.' , e ) ; toggleButton . disabled = false ; setPushDisabled ( ) ; } } ) ; } ) ; }
Subscribes to the push service.
Subscribes to the push service .