When I send the Firebase notification to the app while the app is in the background, the notification appears in the system tray. When the user clicks on the notification, the app opens. In the app, the notification, intent extra provides the data sent with the notification.
if (getIntent().getExtras() != null) {
for (String key : getIntent().getExtras().keySet()) {
Object value = getIntent().getExtras().get(key);
Log.d(TAG, "Key: " + key + " Value: " + value);
}
}
However, it does not include the notification title and body. onMessageReceived
is also not called when background notification is received.
Is there any way to get the title and message body of the background notification? One way I could do it to send them as key-value pairs in Additional options with the notification. It would be great if there is any better way to get the background notification title and body in the app.