Skip to content

Commit 51ae1ee

Browse files
committed
Use GROUP_ALERT_CHILDREN to fix heads up summaries
Using GROUP_ALERT_CHILDREN with setGroupAlertBehavior means the just receive notification will be used as the heads-up, if the notification channel is configured for highest display priority. Before with GROUP_ALERT_SUMMARY, you would see a summary of all notifications in the group which was much harder to see the most recent. This also fixes a bug where the previous notification would be shown as the heads-up notification on some devices. Such as Samsung's OneUI 4 with the Brief style of notifications, as well as some other manufacturers. Lastly the bug would sometimes happen on Android 7 and 8 AOSP since the summary and child notification are posted at the same time and these versions of Android would pick one at random. In this case it seemed to only be an issue when setting android_group and only on the 2nd notification display.
1 parent d3acf89 commit 51ae1ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

OneSignalSDK/onesignal/src/main/java/com/onesignal/GenerateNotification.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ private static void createGenericPendingIntentsForGroup(
385385
notifBuilder.setGroup(group);
386386

387387
try {
388-
notifBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
388+
notifBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
389389
} catch (Throwable t) {
390390
//do nothing in this case...Android support lib 26 isn't in the project
391391
}
@@ -612,7 +612,7 @@ private static void createSummaryNotification(OSNotificationGenerationJob notifi
612612
.setGroupSummary(true);
613613

614614
try {
615-
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
615+
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
616616
}
617617
catch (Throwable t) {
618618
//do nothing in this case...Android support lib 26 isn't in the project
@@ -674,7 +674,7 @@ private static void createSummaryNotification(OSNotificationGenerationJob notifi
674674
.setGroupSummary(true);
675675

676676
try {
677-
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
677+
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
678678
}
679679
catch (Throwable t) {
680680
//do nothing in this case...Android support lib 26 isn't in the project
@@ -730,7 +730,7 @@ private static void createGrouplessSummaryNotification(
730730
.setGroupSummary(true);
731731

732732
try {
733-
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_SUMMARY);
733+
summaryBuilder.setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN);
734734
}
735735
catch (Throwable t) {
736736
// Do nothing in this case... Android support lib 26 isn't in the project

0 commit comments

Comments
 (0)