TF-1898 Fix there is no notification badge only on IOS

(cherry picked from commit c8c8a03267846df5c5d2032553988fd393fbc02d)
This commit is contained in:
dab246
2023-07-10 13:51:24 +07:00
committed by Dat Vu
parent 356a6b8095
commit b939c59fb0
9 changed files with 52 additions and 3 deletions
@@ -26,6 +26,10 @@ class FcmReceiver {
FirebaseMessaging.onBackgroundMessage(handleFirebaseBackgroundMessage);
}
void onMessageOpenedApp() {
FirebaseMessaging.onMessageOpenedApp.listen(FcmService.instance.handleFirebaseMessageOpenedApp);
}
void getFcmToken() async {
try {
final currentToken = await FirebaseMessaging.instance.getToken(vapidKey: AppUtils.fcmVapidPublicKey);
@@ -4,6 +4,7 @@ import 'dart:async';
import 'package:core/utils/app_logger.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:tmail_ui_user/features/push_notification/presentation/controller/fcm_message_controller.dart';
import 'package:tmail_ui_user/features/push_notification/presentation/notification/local_notification_manager.dart';
class FcmService {
@@ -43,6 +44,11 @@ class FcmService {
}
}
void handleFirebaseMessageOpenedApp(RemoteMessage newRemoteMessage) async {
log("FcmService::handleFirebaseMessageOpenedApp:");
await LocalNotificationManager.instance.removeNotificationBadgeForIOS();
}
void handleGetToken(String? currentToken) async {
log('FcmService::handleGetToken():currentToken: $currentToken');
if (fcmTokenStreamController.isClosed) {