Skip to content

Commit 75f9147

Browse files
committed
fix initial notification from killed
1 parent 9ad4f25 commit 75f9147

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java

+15-15
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,13 @@ public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
6161
final IPushNotificationsDrawer notificationsDrawer = PushNotificationsDrawer.get(mApplication.getApplicationContext());
6262
notificationsDrawer.onNewActivity(activity);
6363

64-
Intent intent = activity.getIntent();
65-
if (NotificationIntentAdapter.canHandleIntent(intent)) {
66-
Bundle notificationData = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R ?
67-
NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
68-
final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData);
69-
if (pushNotification != null) {
70-
pushNotification.onOpened();
71-
}
72-
}
64+
callOnOpenedIfNeed(activity);
7365
}
7466

7567
@Override
7668
public void onActivityStarted(Activity activity) {
77-
Bundle bundle = activity.getIntent().getExtras();
78-
if (bundle != null) {
79-
PushNotificationProps props = new PushNotificationProps(bundle);
80-
if (props.isFirebaseBackgroundPayload()) {
81-
InitialNotificationHolder.getInstance().set(props);
82-
}
69+
if (InitialNotificationHolder.getInstance().get() == null) {
70+
callOnOpenedIfNeed(activity);
8371
}
8472
}
8573

@@ -102,4 +90,16 @@ public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
10290
@Override
10391
public void onActivityDestroyed(Activity activity) {
10492
}
93+
94+
private void callOnOpenedIfNeed(Activity activity) {
95+
Intent intent = activity.getIntent();
96+
if (NotificationIntentAdapter.canHandleIntent(intent)) {
97+
Bundle notificationData = android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R ?
98+
NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
99+
final IPushNotification pushNotification = PushNotification.get(mApplication.getApplicationContext(), notificationData);
100+
if (pushNotification != null) {
101+
pushNotification.onOpened();
102+
}
103+
}
104+
}
105105
}

lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java

-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import com.wix.reactnativenotifications.core.InitialNotificationHolder;
1818
import com.wix.reactnativenotifications.core.JsIOHelper;
1919
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
20-
import com.wix.reactnativenotifications.core.ProxyService;
2120

2221
import static com.wix.reactnativenotifications.Defs.NOTIFICATION_OPENED_EVENT_NAME;
2322
import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME;

0 commit comments

Comments
 (0)