|
|
|
@ -77,9 +77,24 @@ class NotificationManger {
|
|
|
|
static final Map<String, int> _groupCounts = {};
|
|
|
|
static final Map<String, int> _groupCounts = {};
|
|
|
|
|
|
|
|
|
|
|
|
static Future<void> _showGroupSummary(String groupId) async {
|
|
|
|
static Future<void> _showGroupSummary(String groupId) async {
|
|
|
|
// Increment count for this group
|
|
|
|
// Query actual active notifications from the system
|
|
|
|
|
|
|
|
final androidPlugin = localNotificationsPlugin.resolvePlatformSpecificImplementation<AndroidFlutterLocalNotificationsPlugin>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final List<ActiveNotification>? 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;
|
|
|
|
_groupCounts[groupId] = (_groupCounts[groupId] ?? 0) + 1;
|
|
|
|
final count = _groupCounts[groupId]!;
|
|
|
|
count = _groupCounts[groupId]!;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Only show summary if we have 2+ notifications
|
|
|
|
// Only show summary if we have 2+ notifications
|
|
|
|
if (count < 2) return;
|
|
|
|
if (count < 2) return;
|
|
|
|
|