I told you that the method:
@Override
public void onMessageReceived(RemoteMessage remoteMessage)
This is done to intercept the push notifications when your application is open, as it says in the Firebase documentation:
Notification messages sent when the app is in the background . In this case, the notification is delivered to the device's system tray. When a user presses a notification, it opens the application selector by default.
Messages with notification and data payloads, both in the foreground and in the second . In this case, the notification is delivered to the system tray of the device and the data load is delivered in the additional ones of the intent of your initiating activity.
In summary, when your application is in the foreground, you can intercept the push (or not) with onMessageReceived, otherwise the Android tray gets it.
Solution
What you should do is send the necessary metadata from the server, for example:
var message = {
data: {
score: '850',
time: '2:45'
},
topic: topic
};
That information will arrive to your device through an Intent in the first screen you have, you can capture it in the following way (the code below should print the values you sent from Firebase):
if (getIntent().getExtras() != null) {
for (String key : getIntent().getExtras().keySet()) {
String value = getIntent().getExtras().getString(key);
Log.d(TAG, "Key: " + key + " Value: " + value);
}
}
I hope it has helped you, regards.