fix: resolve duplicate background notifications and format contact names in local notification titles
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user