title: Web firebase.messaging().onMessage not fired, but background notification perfectly fired
body: <p>I want to reload or trigger some event in foregrounf if push message is sent with firebase.messaging().onMessage, but it not fired. I'm using firebase.mesaging.sw.js with background notification and it works correctly what is wrong with my code?</p>
  
  <p>firebase.js</p>
  
  <pre><code>const config = {
    apiKey: "x",
    projectId: "x",
    storageBucket: "x",
    messagingSenderId: "x"
  };
  
  firebase.initializeApp(config);
  
  const msg = firebase.messaging()
  msg.requestPermission()
    .then(() =&gt; {
      return msg.getToken()
    })
    .then((token) =&gt; {
    })
    .catch((err) =&gt; {
    })
  
  msg.onMessage(function(payload) {
    alert("Foreground message fired!")
    console.log(payload)
  });
  </code></pre>
  
  <p>firebase.messaging.sw.js</p>
  
  <pre><code>importScripts("https://www.gstatic.com/firebasejs/7.0.0/firebase-app.js");
  importScripts("https://www.gstatic.com/firebasejs/7.0.0/firebase-messaging.js");
  
  const config = {
    apiKey: "x",
    projectId: "x",
    storageBucket: 'x',
    messagingSenderId: "x"
  };
  
  firebase.initializeApp(config);
  const msg = firebase.messaging()
  
  msg.setBackgroundMessageHandler(function(payload) {
    let options = {
      body: payload.data.body,
      icon: payload.data.icon
    }
  
    return self.registration.showNotification(payload.data.title, options);
  
  });
  </code></pre>
  
  <p>I don't know what is wrong with my code</p>