Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(messaging): get remote message from messaging store on new intent #4634

Merged
merged 1 commit into from
Dec 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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