Fix notification group summary behavior (double cha-ching) in WooNoti…#15165
Fix notification group summary behavior (double cha-ching) in WooNoti…#15165AlexKlimaj wants to merge 1 commit intowoocommerce:trunkfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where order notifications in the WooCommerce Android app were playing a double "cha-ching" sound. The issue occurred because both the individual notification and the group summary notification were triggering sound alerts.
Key Changes:
- Reordered method calls in
buildAndDisplayWooNotification()to set group alert behavior before setting group summary
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hey @AlexKlimaj thanks for surfacing this issue and attempting to provide a fix for it. I was not able to reproduce the double "cha-ching" issue, so I suspect it is likely an issue with how different OEM/Android devices handle some push notification code. The fix attempt you provided though, I don't think will make any difference. Have you tested that it fixed the bug? Because changing the order on how some values are applied in That being said this is what I suspect is happening is the following:
Why GROUP_ALERT_CHILDREN Might Not Work:
Possible causes:
I think adding the following code: if (!isGroupNotification) {
setGroupSummary(true)
setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN)
setDefaults(0)
setSound(null)
setVibrate(null)
showNotification(notification.getGroupPushId(), notification, this)
}Will fix the issue for all OEMs. I've opened a new PR with the above changes. I'll proceed to close this PR though. Let me know if you have any other feedback. And once again thanks for contributing to making the Woo app better. |
Attempt to fix double cha-ching for every order.
Summary
The problem was in WooNotificationBuilder.kt. When the first order notification arrives:
An individual notification is created and displayed (plays sound ✓)
A group summary notification is also created for non-wearable devices (was playing sound again ✗)
The fix was to call setGroupAlertBehavior(NotificationCompat.GROUP_ALERT_CHILDREN) before setting the group summary. This tells Android to only alert (play sound) for the child notifications, not the summary.
The key change was moving the line from after setGroupSummary(true) to before it, which ensures the alert behavior is set before the summary is created. This prevents the duplicate sound while still maintaining proper notification grouping functionality.