fix: resolve duplicate background notifications and format contact names in local notification titles

This commit is contained in:
Hamza-Ayed
2026-05-18 18:53:24 +03:00
parent b3ef0b89f6
commit 123902a6b1
5 changed files with 42 additions and 10 deletions

View File

@@ -3,6 +3,7 @@ import 'dart:convert';
import 'package:get/get.dart';
import 'package:web_socket_channel/web_socket_channel.dart';
import '../config/app_config.dart';
import 'contacts_service.dart';
import 'firebase_service.dart';
enum WsStatus { disconnected, connecting, connected, waReady }
@@ -104,9 +105,15 @@ class WhatsAppService extends GetxService {
body = '📷 Media/Audio message';
}
try {
final String cleanNumber = chatId?.split('@')[0] ?? '';
final String senderName = Get.find<ContactsService>().getContactName(
cleanNumber,
cleanNumber.isNotEmpty ? '+$cleanNumber' : 'WhatsApp',
);
Get.find<FirebaseService>().showLocalNotificationFromData({
'chatId': chatId,
'name': chatId?.split('@')[0] ?? 'WhatsApp',
'name': senderName,
'body': body,
});
} catch (e) {