TF-1246: Enable FCM for Web browser
This commit is contained in:
@@ -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