Skip to content

Commit

Permalink
fix(messaging): remote message from messaging store on new intent (#4634
Browse files Browse the repository at this point in the history
)
  • Loading branch information
dlindstrm authored Dec 2, 2020
1 parent 11867da commit 00b83af
Showing 1 changed file with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public class ReactNativeFirebaseMessagingModule extends ReactNativeFirebaseModul
reactContext.addActivityEventListener(this);
}

private RemoteMessage popRemoteMessageFromMessagingStore(String messageId) {
ReactNativeFirebaseMessagingStore messagingStore = ReactNativeFirebaseMessagingStoreHelper.getInstance().getMessagingStore();
RemoteMessage remoteMessage = messagingStore.getFirebaseMessage(messageId);
messagingStore.clearFirebaseMessage(messageId);
return remoteMessage;
}

@ReactMethod
public void getInitialNotification(Promise promise) {
if (initialNotification != null) {
Expand All @@ -70,9 +77,7 @@ public void getInitialNotification(Promise promise) {
if (messageId != null && initialNotificationMap.get(messageId) == null) {
RemoteMessage remoteMessage = ReactNativeFirebaseMessagingReceiver.notifications.get(messageId);
if (remoteMessage == null) {
ReactNativeFirebaseMessagingStore messagingStore = ReactNativeFirebaseMessagingStoreHelper.getInstance().getMessagingStore();
remoteMessage = messagingStore.getFirebaseMessage(messageId);
messagingStore.clearFirebaseMessage(messageId);
remoteMessage = popRemoteMessageFromMessagingStore(messageId);
}
if (remoteMessage != null) {
promise.resolve(ReactNativeFirebaseMessagingSerializer.remoteMessageToWritableMap(remoteMessage));
Expand Down Expand Up @@ -212,6 +217,9 @@ public void onNewIntent(Intent intent) {

if (messageId != null) {
RemoteMessage remoteMessage = ReactNativeFirebaseMessagingReceiver.notifications.get(messageId);
if (remoteMessage == null) {
remoteMessage = popRemoteMessageFromMessagingStore(messageId);
}

if (remoteMessage != null) {
initialNotification = remoteMessage;
Expand Down

1 comment on commit 00b83af

@vercel
Copy link

@vercel vercel bot commented on 00b83af Dec 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.