feat(messaging,android): save notification payload for messages that arrive in the foreground (#3896)

This commit is contained in:
Aranda Morrison
2020-07-24 18:14:12 +08:00
committed by GitHub
parent 7e9d252853
commit ff768fce54

View File

@@ -26,6 +26,11 @@ public class ReactNativeFirebaseMessagingReceiver extends BroadcastReceiver {
RemoteMessage remoteMessage = new RemoteMessage(intent.getExtras());
ReactNativeFirebaseEventEmitter emitter = ReactNativeFirebaseEventEmitter.getSharedInstance();
// Add a RemoteMessage if the message contains a notification payload
if (remoteMessage.getNotification() != null) {
notifications.put(remoteMessage.getMessageId(), remoteMessage);
}
// |-> ---------------------
// App in Foreground
// ------------------------
@@ -39,11 +44,6 @@ public class ReactNativeFirebaseMessagingReceiver extends BroadcastReceiver {
// App in Background/Quit
// ------------------------
// Add a RemoteMessage if the message contains a notification payload
if (remoteMessage.getNotification() != null) {
notifications.put(remoteMessage.getMessageId(), remoteMessage);
}
try {
Intent backgroundIntent = new Intent(context, ReactNativeFirebaseMessagingHeadlessService.class);
backgroundIntent.putExtra("message", remoteMessage);