title: Firebase - notificationclick event not receiving payload
body: <p>I'm struggling with this problem for more than a week... We have implemented push message in Chrome by using Firebase and a Service Worker. Everything works just fine, the messages are being sent and received correctly with the payload. On the service worker, we handle the push message to display a notification and the notificationclick event to send the user to a specific URL when clicking on it, then close the notification.</p>
  <p>The problem is with 'old' notifications: if a user receives a message but doesn't clicks on it right away, it keeps there for a while then after some time (not sure how much) he clicks the notification - he gets redirected to https://[domain]/firebase-messaging-sw.js
  We have traced the entire process: the notification gets received with all the info properly (the url is also correct, actually if he clicks right when the message is received it works just fine). But if the notification lives there for a while it gets 'emptied'.</p>
  <p>The message being sent is pretty simple (just for showing there are no TTLs, nor expiration parameters being used). The curl command looks like that:</p>
  <pre class="lang-phpsql prettyprint-override"><code>curl -X POST 
      -H &quot;Authorization: key=[SERVER API KEY]&quot;
      -H &quot;Content-Type: application/json&quot;
      -d '{
      &quot;notification&quot;:{
          &quot;click_action&quot;:&quot;[URL to be redirected]&quot;,
          &quot;icon&quot;:&quot;[A custom image]&quot;,
          &quot;title&quot;:&quot;[News title]&quot;},
          &quot;to&quot;:&quot;/topics/[A topic]&quot;
      }' 
  &quot;https://fcm.googleapis.com/fcm/send&quot;
  
  </code></pre>
  <p>This is the code for processing the push message on the service worker:</p>
  <pre class="lang-js prettyprint-override"><code>self.addEventListener('push', function(event) {
      console.log('Push message received', event);
      var data = {};
      if (event.data) {
          data = event.data.json();
      }
      event.stopImmediatePropagation();
      showNotification(data.notification);
  });
  
  function showNotification(notification) {
      var click_action = notification.click_action; //&lt;-- This is correct!
      var options = {
          body: notification.body,
          icon: notification.icon,
          subtitle: notification.subtitle,
          data: {
              url: click_action
          }
      };
      if (self.registration.showNotification) {
          return self.registration.showNotification(notification.title, options);
      }
  }
  </code></pre>
  <p>And the code for managing notificationclick event is pretty straightforward:</p>
  <pre class="lang-js prettyprint-override"><code>self.addEventListener('notificationclick', function(event) {
      var url = '';
      try {
          url = event.notification.data.url; // &lt;-- event.notification is null randomly!!
      } catch (err) {}
      event.waitUntil(self.clients.openWindow(url));
  });
  </code></pre>
  <p>Is there any reason for loosing the payload after a certain time on the service worker context? Is this time specified on any documentation somewhere?
  Thanks in advance for your help!</p>