diff --git a/lib/controllers/notification/notification_manger.dart b/lib/controllers/notification/notification_manger.dart index 94311ae9..af91ccab 100644 --- a/lib/controllers/notification/notification_manger.dart +++ b/lib/controllers/notification/notification_manger.dart @@ -77,9 +77,24 @@ class NotificationManger { static final Map _groupCounts = {}; static Future _showGroupSummary(String groupId) async { - // Increment count for this group - _groupCounts[groupId] = (_groupCounts[groupId] ?? 0) + 1; - final count = _groupCounts[groupId]!; + // Query actual active notifications from the system + final androidPlugin = localNotificationsPlugin.resolvePlatformSpecificImplementation(); + + final List? activeNotifications = await androidPlugin?.getActiveNotifications(); + + // Count notifications that actually exist in this group (exclude summary itself) + int count = 0; + if (activeNotifications != null) { + count = activeNotifications.where((notification) { + return notification.groupKey == groupId && notification.id != groupId.hashCode; // Exclude summary notification + }).length; + } + + // Fallback to in-memory count if query fails (for older Android versions) + if (count == 0) { + _groupCounts[groupId] = (_groupCounts[groupId] ?? 0) + 1; + count = _groupCounts[groupId]!; + } // Only show summary if we have 2+ notifications if (count < 2) return;