Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lyz committed Oct 12, 2022
1 parent a18a593 commit 348eb9b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void onActivityResult(Activity activity, int requestCode, int resultCode,
@Override
public void onNewIntent(Intent intent) {
if (NotificationIntentAdapter.canHandleIntent(intent)) {
Bundle notificationData = intent.getExtras();
Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData);
if (notification != null) {
notification.onOpened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ private void callOnOpenedIfNeed(Activity activity) {
Intent intent = activity.getIntent();
if (NotificationIntentAdapter.canHandleIntent(intent)) {
Context appContext = mApplication.getApplicationContext();
Bundle notificationData = NotificationIntentAdapter.cannotHandleTrampolineActivity(appContext) ?
NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras();
Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent);
final IPushNotification pushNotification = PushNotification.get(appContext, notificationData);
if (pushNotification != null) {
pushNotification.onOpened();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,9 @@ public class NotificationIntentAdapter {

@SuppressLint("UnspecifiedImmutableFlag")
public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) {
if (cannotHandleTrampolineActivity(appContext)) {
Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext);
taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent);
return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
} else {
Intent intent = new Intent(appContext, ProxyService.class);
intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT);
}
Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName());
intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle());
return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE);
}

public static boolean cannotHandleTrampolineActivity(Context appContext) {
Expand Down

0 comments on commit 348eb9b

Please sign in to comment.