Skip to content

Commit

Permalink
Fix: Add FLAG_MUTABLE to pending intents for SDK 31 support
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspeon-hero committed Apr 10, 2023
1 parent 9c1f17f commit a21a6d5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/android/ForegroundService.java
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,16 @@ private Notification makeNotification (JSONObject settings)
setColor(notification, settings);

if (intent != null && settings.optBoolean("resume")) {
int flags = PendingIntent.FLAG_UPDATE_CURRENT;

if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
flags = flags | PendingIntent.FLAG_MUTABLE;
}

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(
context, NOTIFICATION_ID, intent,
PendingIntent.FLAG_IMMUTABLE);
flags);


notification.setContentIntent(contentIntent);
Expand Down

0 comments on commit a21a6d5

Please sign in to comment.