From 14a32d101ec5fe2e0f90faa02f14e9b19430b124 Mon Sep 17 00:00:00 2001 From: Sikander Saleem Date: Mon, 6 Jul 2026 10:49:42 +0300 Subject: [PATCH] improvements --- .../notification/firebase_notification_manger.dart | 11 ++++++++--- lib/controllers/notification/notification_manger.dart | 4 +++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/controllers/notification/firebase_notification_manger.dart b/lib/controllers/notification/firebase_notification_manger.dart index ea860ae0..76468734 100644 --- a/lib/controllers/notification/firebase_notification_manger.dart +++ b/lib/controllers/notification/firebase_notification_manger.dart @@ -241,7 +241,7 @@ class FirebaseNotificationManger { } await FirebaseMessaging.instance.setAutoInitEnabled(true); - await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(alert: true, badge: true, sound: true); + await FirebaseMessaging.instance.setForegroundNotificationPresentationOptions(alert: true, badge: false, sound: true); FirebaseMessaging.instance.getInitialMessage().then((initialMessage) { if (initialMessage != null) { @@ -252,9 +252,14 @@ class FirebaseNotificationManger { FirebaseMessaging.onMessage.listen((RemoteMessage message) { if (Platform.isAndroid) { if (message.data["notificationType"] != 'NurseConfirmArrive') { + // Extract title and body from notification field first, fallback to data field + final String title = message.notification?.title ?? message.data['title'] ?? 'ATOMS'; + final String body = message.notification?.body ?? message.data['body'] ?? 'New notification'; + + // Always show with our grouping logic NotificationManger.showNotification( - title: message.notification?.title ?? "", - subtext: message.notification?.body ?? "", + title: title, + subtext: body, hashcode: DateTime.now().millisecondsSinceEpoch.hashCode, payload: json.encode(message.data), context: context); diff --git a/lib/controllers/notification/notification_manger.dart b/lib/controllers/notification/notification_manger.dart index 5e85c450..94311ae9 100644 --- a/lib/controllers/notification/notification_manger.dart +++ b/lib/controllers/notification/notification_manger.dart @@ -56,6 +56,7 @@ class NotificationManger { visibility: NotificationVisibility.public, enableVibration: true, groupKey: groupId ?? 'com.hmg.atoms', + setAsGroupSummary: false, ); static DarwinNotificationDetails iosNotificationDetails(String? threadId) => DarwinNotificationDetails(categoryIdentifier: "atoms", threadIdentifier: threadId); @@ -92,7 +93,8 @@ class NotificationManger { icon: "@drawable/ic_stat_name", groupKey: groupId, setAsGroupSummary: true, - // THIS IS THE KEY + onlyAlertOnce: true, + autoCancel: true, styleInformation: InboxStyleInformation( [], contentTitle: 'ATOMS',