Skip to content

Commit

Permalink
android-get-initial-notification (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielEliraz committed Jul 20, 2023
1 parent 7925280 commit 748e219
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,13 @@ private void callOnOpenedIfNeed(Activity activity) {
Intent intent = activity.getIntent();
if (NotificationIntentAdapter.canHandleIntent(intent)) {
Context appContext = mApplication.getApplicationContext();
Bundle notificationData = NotificationIntentAdapter.canHandleTrampolineActivity(appContext) ?
intent.getExtras() : NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
if (pushNotification != null) {
pushNotification.onOpened();
// Erase notification intent after using it, to avoid looping with the same notification
// in case the app is moved to background and opened again
activity.setIntent(new Intent());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ public static boolean canHandleTrampolineActivity(Context appContext) {
}

public static Bundle extractPendingNotificationDataFromIntent(Intent intent) {
return intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME);
Bundle notificationBundle = intent.getBundleExtra(PUSH_NOTIFICATION_EXTRA_NAME);
if (notificationBundle != null) {
return notificationBundle;
} else {
return intent.getExtras();
}
}

public static boolean canHandleIntent(Intent intent) {
Expand Down

0 comments on commit 748e219

Please sign in to comment.