fix(notifications/action): use radom request code

Fixes the issue with pendingIntents overwriting each other. Probability of equal same request code should be near 0 with 2^32 ints available
This commit is contained in:
FineFindus 2023-02-27 20:24:09 +01:00
parent 0b58d19811
commit 2dc6deb93a
No known key found for this signature in database
GPG Key ID: 64873EE210FF8E6B
1 changed files with 2 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import org.parceler.Parcels;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.stream.Collectors;
import me.grishka.appkit.api.Callback;
@ -227,7 +228,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
notificationIntent.putExtra("notificationAction", action.ordinal());
notificationIntent.putExtra("notification", Parcels.wrap(notification));
PendingIntent actionPendingIntent =
PendingIntent.getBroadcast(context, 1, notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent.getBroadcast(context, new Random().nextInt(), notificationIntent, PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_ONE_SHOT);
return new Notification.Action.Builder(null, title, actionPendingIntent).build();
}