Skip to content

Commit

Permalink
Merge pull request #1603 from OneSignal/fix/groupless_heads_up_redisplay
Browse files Browse the repository at this point in the history
[Fix] groupless heads-up style notifications from redisplaying previous
  • Loading branch information
jkasten2 authored Jun 21, 2022
2 parents da8c8d8 + 9d76b27 commit cfa20cc
Showing 1 changed file with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,19 +100,16 @@ static ArrayList<StatusBarNotification> getActiveGrouplessNotifications(Context
/**
* All groupless notifications are assigned the GROUPLESS_SUMMARY_KEY and notify() is called
*/
@RequiresApi(api = Build.VERSION_CODES.M)
@RequiresApi(api = Build.VERSION_CODES.N)
static void assignGrouplessNotifications(Context context, ArrayList<StatusBarNotification> grouplessNotifs) {
for (StatusBarNotification grouplessNotif : grouplessNotifs) {
Notification.Builder grouplessNotifBuilder;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
grouplessNotifBuilder = Notification.Builder.recoverBuilder(context, grouplessNotif.getNotification());
} else {
grouplessNotifBuilder = new Notification.Builder(context);
}
Notification.Builder grouplessNotifBuilder =
Notification.Builder.recoverBuilder(context, grouplessNotif.getNotification());

// Recreate the notification but with the groupless key instead
Notification notif = grouplessNotifBuilder
.setGroup(GROUPLESS_SUMMARY_KEY)
.setOnlyAlertOnce(true)
.build();

NotificationManagerCompat.from(context).notify(grouplessNotif.getId(), notif);
Expand Down

0 comments on commit cfa20cc

Please sign in to comment.