feat: Implement push notification suppression for active chats, prevent duplicate self-messages, update the chat typing indicator, and add back buttons to static screens.

This commit is contained in:
pradeepkumar
2026-03-18 17:24:32 +05:30
parent cde137e07b
commit a4aa9bfe25
8 changed files with 196 additions and 35 deletions

View File

@@ -29,6 +29,10 @@ class PushNotificationService {
/// Callback when user taps a notification — set by the app to navigate.
void Function(String? actionUrl)? onNotificationTap;
/// The conversation ID currently being viewed — suppress message push
/// notifications for this conversation to avoid self-notifications.
String? activeConversationId;
/// Initialize Firebase Messaging and local notifications.
Future<void> initialize() async {
if (_initialized) return;
@@ -159,6 +163,14 @@ class PushNotificationService {
final notification = message.notification;
if (notification == null) return;
// Suppress message push notifications when user is viewing that conversation
final msgType = message.data['type'] as String?;
final convId = message.data['conversationId'] as String?;
if (msgType == 'message' && convId != null && convId == activeConversationId) {
debugPrint('[FCM] Suppressed notification — user is viewing conversation $convId');
return;
}
// Show local notification on Android (iOS handles it natively)
if (Platform.isAndroid) {
_localNotifications?.show(