Skip to content

Commit

Permalink
android-get-initial-notification (#983)
Browse files Browse the repository at this point in the history
DanielEliraz authored Jul 20, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 7925280 commit 748e219
Showing 2 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -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());
}
}
}
Original file line number Diff line number Diff line change
@@ -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) {

0 comments on commit 748e219

Please sign in to comment.