title: Retrieve notification values from a notification in system tray android firebase FCM
body: <p>I am using firebase to send notifications to my app. I want to save the notifications received on each device in a local database. The problem is, when the app is in the background and a notification is received, the method <code>onMessageReceived()</code> won't be called, but instead the notification would be added to the system tray as per documentation. The documentation also mentions the following for receiving a notification when the app is in background: </p>
  
  <blockquote>
    <p>In these cases, the notification is delivered to the device's system tray, and the data payload is delivered in the extras of the intent of your launcher Activity.</p>
  </blockquote>
  
  <p>So, when I'm trying to access the extras in the intent, the keys of the notification are not found.
  My code in <code>MainActivity.java</code>:</p>
  
  <pre><code>if (getIntent().getExtras() != null) {
          for (String key : getIntent().getExtras().keySet()) {
              Object value = getIntent().getExtras().get(key);
              Toast.makeText(this, "Key: " + key + " Value: " + value, Toast.LENGTH_LONG).show();
          }
      }
  </code></pre>
  
  <p>The notification we are sending from the server:</p>
  
  <pre><code>{
  "to" : "bk3RNwTe3H0:CI2k_HHwgIpoDKCIZvvDMExUdFQ3P1...",
  "notification" : {
    "body" : "great match!",
    "title" : "Portugal vs. Denmark",
    "icon" : "myicon"
    }
  }
  </code></pre>
  
  <p>Anyone has an idea of how I can retrieve the values inside the notification?</p>