title: Create-react-app registerServiceWorker giving undefined at getRegistration() promise
body: <p>First, it is working on PC but doesn't on a mobile device, that is my main problem.</p>
  
  <p>I created a PWA using create-react-app and I'm trying to implement push notifications but seems like I get undefined at the 'reg' argument of my promise. Someone knows how to make this works? I already try to eject create-react-app but gives the same problem.</p>
  
  <p>I added this code to <strong>registerServiceWorker.js</strong>:</p>
  
  <pre><code>export function displayNotification() {
    if (Notification.permission === 'granted') {
      console.log('this is showing at console when i click the button')
      navigator.serviceWorker.getRegistration().then(function(reg) {
        reg.showNotification('Hello world!');
      });
    }
  }
  </code></pre>
  
  <p><strong>Error:</strong></p>
  
  <blockquote>
    <p>Unhandled Rejection (TypeError): Cannot read property
    'showNotification' of undefined</p>
  </blockquote>
  
  <p>This issue talks about this problem but I already tried those solutions and the error is the same.</p>
  
  <p><a href="https://github.com/facebook/create-react-app/issues/2253#issuecomment-312359460" rel="nofollow noreferrer">https://github.com/facebook/create-react-app/issues/2253#issuecomment-312359460</a></p>
  
  <p>Those below are an old version that only works at browser PC, and at PWA gives a blank page when clicking the button.</p>
  
  <p>My PWA: <a href="https://danilosilvadev.github.io/pwa-test/" rel="nofollow noreferrer">https://danilosilvadev.github.io/pwa-test/</a></p>
  
  <p>My code: <a href="https://github.com/danilosilvadev/pwa-test/tree/master" rel="nofollow noreferrer">https://github.com/danilosilvadev/pwa-test/tree/master</a></p>
  
  <p>If help me with this old version that uses an npm package called <em>"react-web-notification": "^0.3.1"</em> or with the code that I provided in this question that is my attempt to do manually anyway I'd be grateful.</p>