-
-
Notifications
You must be signed in to change notification settings - Fork 137
Open
Description
Description:
When targeting Android 14 (SDK 34+), the app crashes due to usage of a PendingIntent
with FLAG_MUTABLE
and an implicit intent in RNBackgroundActionsTask.java
. This behavior is restricted by the OS for security reasons.
To Reproduce:
Set compileSdkVersion = 34 and targetSdkVersion = 34
Use react-native-background-actions to run a background task
Observe crash logs:
java.lang.IllegalArgumentException: Targeting U+ disallows creating or retrieving a PendingIntent with FLAG_MUTABLE and an implicit Intent...
Problematic Code (Current Implementation):
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, PendingIntent.FLAG_MUTABLE);
}
Proposed Fix:
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
if (intent != null) {
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
contentIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_IMMUTABLE);
}
Metadata
Metadata
Assignees
Labels
No labels