diff --git a/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java index e3f177a50..9f568b8f2 100644 --- a/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +++ b/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java @@ -61,25 +61,13 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState) { final IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(mApplication.getApplicationContext()); notificationsDrawer.onNewActivity(activity); - Intent intent = activity.getIntent(); - if (NotificationIntentAdapter.canHandleIntent(intent)) { - Bundle notificationData = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R ? - NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras(); - final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData); - if (pushNotification != null) { - pushNotification.onOpened(); - } - } + callOnOpenedIfNeed(activity); } @Override public void onActivityStarted(Activity activity) { - Bundle bundle = activity.getIntent().getExtras(); - if (bundle != null) { - PushNotificationProps props = new PushNotificationProps(bundle); - if (props.isFirebaseBackgroundPayload()) { - InitialNotificationHolder.getInstance().set(props); - } + if (InitialNotificationHolder.getInstance().get() == null) { + callOnOpenedIfNeed(activity); } } @@ -102,4 +90,16 @@ public void onActivitySaveInstanceState(Activity activity, Bundle outState) { @Override public void onActivityDestroyed(Activity activity) { } + + private void callOnOpenedIfNeed(Activity activity) { + Intent intent = activity.getIntent(); + if (NotificationIntentAdapter.canHandleIntent(intent)) { + Bundle notificationData = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R ? + NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras(); + final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData); + if (pushNotification != null) { + pushNotification.onOpened(); + } + } + } } diff --git a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java index d24eccfe4..dedc98ad6 100644 --- a/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -17,7 +17,6 @@ import com.wix.reactnativenotifications.core.InitialNotificationHolder; import com.wix.reactnativenotifications.core.JsIOHelper; import com.wix.reactnativenotifications.core.NotificationIntentAdapter; -import com.wix.reactnativenotifications.core.ProxyService; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_OPENED_EVENT_NAME; import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME;