title: How to make a Laravel pusher notification to display in background?
body: <p>I have an application written in Laravel and pusher, my notification works very fine but I want it to work when browser is closed so that user can receive notifications even when browser is not open.</p>
  
  <p>Below is the code i am trying to register a service worker but it is not working.</p>
  
  <p></p>
  
  <pre><code>  if ('serviceWorker' in navigator) {
      window.addEventListener('load',()=&gt;{
        navigator.serviceWorker
          .register('service-worker.js')
          .then(reg=&gt;console.log('Service Worker: Registered'))
          .catch(err=&gt; console.log(`Service Worker : Error: ${err}`));
      })
    }
  
    &lt;/script&gt; 
  </code></pre>