File tree 2 files changed +10
-3
lines changed
lib/android/app/src/main/java/com/wix/reactnativenotifications
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) {
95
95
Intent intent = activity .getIntent ();
96
96
if (NotificationIntentAdapter .canHandleIntent (intent )) {
97
97
Context appContext = mApplication .getApplicationContext ();
98
- Bundle notificationData = NotificationIntentAdapter .canHandleTrampolineActivity (appContext ) ?
99
- intent .getExtras () : NotificationIntentAdapter .extractPendingNotificationDataFromIntent (intent );
98
+ Bundle notificationData = NotificationIntentAdapter .extractPendingNotificationDataFromIntent (intent );
100
99
final IPushNotification pushNotification = PushNotification .get (appContext , notificationData );
101
100
if (pushNotification != null ) {
102
101
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 ());
103
105
}
104
106
}
105
107
}
Original file line number Diff line number Diff line change @@ -32,7 +32,12 @@ public static boolean canHandleTrampolineActivity(Context appContext) {
32
32
}
33
33
34
34
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
+ }
36
41
}
37
42
38
43
public static boolean canHandleIntent (Intent intent ) {
You can’t perform that action at this time.
0 commit comments