File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed
lib/android/app/src/main/java/com/wix/reactnativenotifications Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -95,11 +95,13 @@ private void callOnOpenedIfNeed(Activity activity) {
9595 Intent intent = activity .getIntent ();
9696 if (NotificationIntentAdapter .canHandleIntent (intent )) {
9797 Context appContext = mApplication .getApplicationContext ();
98- Bundle notificationData = NotificationIntentAdapter .canHandleTrampolineActivity (appContext ) ?
99- intent .getExtras () : NotificationIntentAdapter .extractPendingNotificationDataFromIntent (intent );
98+ Bundle notificationData = NotificationIntentAdapter .extractPendingNotificationDataFromIntent (intent );
10099 final IPushNotification pushNotification = PushNotification .get (appContext , notificationData );
101100 if (pushNotification != null ) {
102101 pushNotification .onOpened ();
102+ // Erase notification intent after using it, to avoid looping with the same notification
103+ // in case the app is moved to background and opened again
104+ activity .setIntent (new Intent ());
103105 }
104106 }
105107 }
Original file line number Diff line number Diff line change @@ -32,7 +32,12 @@ public static boolean canHandleTrampolineActivity(Context appContext) {
3232 }
3333
3434 public static Bundle extractPendingNotificationDataFromIntent (Intent intent ) {
35- return intent .getBundleExtra (PUSH_NOTIFICATION_EXTRA_NAME );
35+ Bundle notificationBundle = intent .getBundleExtra (PUSH_NOTIFICATION_EXTRA_NAME );
36+ if (notificationBundle != null ) {
37+ return notificationBundle ;
38+ } else {
39+ return intent .getExtras ();
40+ }
3641 }
3742
3843 public static boolean canHandleIntent (Intent intent ) {
You can’t perform that action at this time.
0 commit comments