TF-1246: Enable FCM for Web browser
This commit is contained in:
@@ -9,6 +9,7 @@ import 'package:core/utils/app_logger.dart';
|
||||
import 'package:core/utils/fps_manager.dart';
|
||||
import 'package:dartz/dartz.dart';
|
||||
import 'package:fcm/model/firebase_capability.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:forward/forward/capability_forward.dart';
|
||||
@@ -162,14 +163,16 @@ abstract class BaseController extends GetxController
|
||||
if (AppConfig.fcmAvailable) {
|
||||
await AppUtils.loadFcmConfigFile();
|
||||
FcmConfiguration.initialize();
|
||||
await LocalNotificationManager.instance.setUp();
|
||||
if (!kIsWeb) {
|
||||
await LocalNotificationManager.instance.setUp();
|
||||
}
|
||||
FcmInteractorBindings().dependencies();
|
||||
FcmController.instance.initialize(accountId: accountId);
|
||||
} else {
|
||||
throw NotSupportFCMException();
|
||||
}
|
||||
} catch(e) {
|
||||
logError('BaseController::injectFirebaseBindings(): exception: $e');
|
||||
logError('BaseController::injectFCMBindings(): exception: $e');
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -1058,6 +1058,7 @@ class MailboxDashBoardController extends ReloadableController {
|
||||
_handleComposerCache();
|
||||
injectAutoCompleteBindings(sessionCurrent, accountId.value);
|
||||
injectRuleFilterBindings(sessionCurrent, accountId.value);
|
||||
injectFCMBindings(sessionCurrent, accountId.value);
|
||||
injectVacationBindings(sessionCurrent, accountId.value);
|
||||
_getVacationResponse();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
class NotSupportFCMException implements Exception {}
|
||||
|
||||
class NotLoadedFCMTokenException implements Exception {}
|
||||
|
||||
class NotFoundStateToRefreshException implements Exception {}
|
||||
|
||||
class NotFoundEmailDeliveryStateException implements Exception {}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
|
||||
import 'package:core/utils/app_logger.dart';
|
||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_exception.dart';
|
||||
import 'package:tmail_ui_user/features/push_notification/presentation/services/fcm_service.dart';
|
||||
|
||||
@pragma('vm:entry-point')
|
||||
@@ -26,9 +29,14 @@ class FcmReceiver {
|
||||
}
|
||||
|
||||
void getFcmToken() async {
|
||||
final token = await FirebaseMessaging.instance.getToken();
|
||||
log('FcmReceiver::onFcmToken():token: $token');
|
||||
FcmService.instance.handleRefreshToken(token);
|
||||
try {
|
||||
final token = await FirebaseMessaging.instance.getToken(vapidKey: kIsWeb ? dotenv.get('FIREBASE_WEB_VAPID_PUBLIC_KEY', fallback: '') : null);
|
||||
log('FcmReceiver::onFcmToken():token: $token');
|
||||
FcmService.instance.handleRefreshToken(token);
|
||||
} catch(e) {
|
||||
log('FcmReceiver::onFcmToken():exception: $e');
|
||||
throw NotLoadedFCMTokenException();
|
||||
}
|
||||
}
|
||||
|
||||
void onRefreshFcmToken() {
|
||||
|
||||
Reference in New Issue
Block a user