@@ -14,19 +14,23 @@ public class NotificationIntentAdapter {
1414
1515 @ SuppressLint ("UnspecifiedImmutableFlag" )
1616 public static PendingIntent createPendingNotificationIntent (Context appContext , PushNotificationProps notification ) {
17- if (android . os . Build . VERSION . SDK_INT >= android . os . Build . VERSION_CODES . R ) {
17+ if (cannotHandleTrampolineActivity ( appContext ) ) {
1818 Intent mainActivityIntent = appContext .getPackageManager ().getLaunchIntentForPackage (appContext .getPackageName ());
1919 mainActivityIntent .putExtra (PUSH_NOTIFICATION_EXTRA_NAME , notification .asBundle ());
2020 TaskStackBuilder taskStackBuilder = TaskStackBuilder .create (appContext );
2121 taskStackBuilder .addNextIntentWithParentStack (mainActivityIntent );
22- return taskStackBuilder .getPendingIntent (0 , PendingIntent .FLAG_ONE_SHOT | PendingIntent .FLAG_IMMUTABLE );
22+ return taskStackBuilder .getPendingIntent (( int ) System . currentTimeMillis (), PendingIntent . FLAG_UPDATE_CURRENT | PendingIntent .FLAG_ONE_SHOT | PendingIntent .FLAG_IMMUTABLE );
2323 } else {
2424 Intent intent = new Intent (appContext , ProxyService .class );
2525 intent .putExtra (PUSH_NOTIFICATION_EXTRA_NAME , notification .asBundle ());
2626 return PendingIntent .getService (appContext , (int ) System .currentTimeMillis (), intent , PendingIntent .FLAG_ONE_SHOT );
2727 }
2828 }
2929
30+ public static boolean cannotHandleTrampolineActivity (Context appContext ) {
31+ return android .os .Build .VERSION .SDK_INT >= android .os .Build .VERSION_CODES .R && appContext .getApplicationInfo ().targetSdkVersion >= 31 ;
32+ }
33+
3034 public static Bundle extractPendingNotificationDataFromIntent (Intent intent ) {
3135 return intent .getBundleExtra (PUSH_NOTIFICATION_EXTRA_NAME );
3236 }
0 commit comments