TF-1205: rename class
This commit is contained in:
@@ -41,7 +41,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.linagora.android.teammail"
|
applicationId "com.linagora.android.teammail"
|
||||||
minSdkVersion 19
|
minSdkVersion 19
|
||||||
targetSdkVersion 33
|
targetSdkVersion 32
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
// The number of method references in a .dex file cannot exceed 64K
|
// The number of method references in a .dex file cannot exceed 64K
|
||||||
|
|||||||
@@ -54,11 +54,16 @@
|
|||||||
android:name="io.flutter.embedding.android.NormalTheme"
|
android:name="io.flutter.embedding.android.NormalTheme"
|
||||||
android:resource="@style/NormalTheme"
|
android:resource="@style/NormalTheme"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- Displays an Android View that continues showing the launch screen
|
<!-- Displays an Android View that continues showing the launch screen
|
||||||
Drawable until Flutter paints its first frame, then this splash
|
Drawable until Flutter paints its first frame, then this splash
|
||||||
screen fades out. A splash screen is useful to avoid any visual
|
screen fades out. A splash screen is useful to avoid any visual
|
||||||
gap between the end of Android's launch screen and the painting of
|
gap between the end of Android's launch screen and the painting of
|
||||||
Flutter's first frame. -->
|
Flutter's first frame. -->
|
||||||
|
<meta-data
|
||||||
|
android:name="io.flutter.embedding.android.SplashScreenDrawable"
|
||||||
|
android:resource="@drawable/launch_background"
|
||||||
|
/>
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
<category android:name="android.intent.category.LAUNCHER"/>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
FIREBASE_ANDROID_API_KEY=example
|
||||||
|
FIREBASE_ANDROID_APP_ID=example
|
||||||
|
FIREBASE_ANDROID_MESSAGING_SENDER_ID=example
|
||||||
|
FIREBASE_ANDROID_PROJECT_ID=example
|
||||||
|
FIREBASE_ANDROID_DATABASE_URL=https://example.com
|
||||||
|
FIREBASE_ANDROID_STORAGE_BUCKET=example.com
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
- Now only support to Android
|
- Now only support to Android
|
||||||
### How to config
|
### How to config
|
||||||
|
|
||||||
1.Add environment of FCM service in [env.file](https://github.com/linagora/tmail-flutter/blob/master/env.file)
|
1.Add environment of FCM service in [env.fcm](https://github.com/linagora/tmail-flutter/blob/master/configurations/env.fcm)
|
||||||
```
|
```
|
||||||
FIREBASE_ANDROID_API_KEY=abc
|
FIREBASE_ANDROID_API_KEY=abc
|
||||||
FIREBASE_ANDROID_APP_ID=abc
|
FIREBASE_ANDROID_APP_ID=abc
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
SERVER_URL=http://localhost/
|
SERVER_URL=http://localhost
|
||||||
DOMAIN_REDIRECT_URL=http://localhost:3000
|
DOMAIN_REDIRECT_URL=http://localhost:3000
|
||||||
WEB_OIDC_CLIENT_ID=teammail-web
|
WEB_OIDC_CLIENT_ID=teammail-web
|
||||||
APP_GRID_AVAILABLE=supported
|
APP_GRID_AVAILABLE=supported
|
||||||
|
FCM_AVAILABLE=unsupported
|
||||||
+2
-2
@@ -55,7 +55,7 @@ PODS:
|
|||||||
- firebase_core (2.2.0):
|
- firebase_core (2.2.0):
|
||||||
- Firebase/CoreOnly (= 10.1.0)
|
- Firebase/CoreOnly (= 10.1.0)
|
||||||
- Flutter
|
- Flutter
|
||||||
- firebase_messaging (14.1.0):
|
- firebase_messaging (14.0.4):
|
||||||
- Firebase/Messaging (= 10.1.0)
|
- Firebase/Messaging (= 10.1.0)
|
||||||
- firebase_core
|
- firebase_core
|
||||||
- Flutter
|
- Flutter
|
||||||
@@ -292,7 +292,7 @@ SPEC CHECKSUMS:
|
|||||||
file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95
|
file_picker: 817ab1d8cd2da9d2da412a417162deee3500fc95
|
||||||
Firebase: 444b35a9c568a516666213c2f6cccd10cb12559f
|
Firebase: 444b35a9c568a516666213c2f6cccd10cb12559f
|
||||||
firebase_core: d2242c6f318db1d0dcecfbfa491e943337b0d755
|
firebase_core: d2242c6f318db1d0dcecfbfa491e943337b0d755
|
||||||
firebase_messaging: 59f435c4cd0d5448e7268a7f70bce9b1287c1742
|
firebase_messaging: 9b704e183cbcc36120b4744eb966c1947baf47a6
|
||||||
FirebaseCore: 55e7ae35991ccca4db03ff8d8df6ed5f17a3e4c7
|
FirebaseCore: 55e7ae35991ccca4db03ff8d8df6ed5f17a3e4c7
|
||||||
FirebaseCoreInternal: 091bde13e47bb1c5e9fe397634f3593dc390430f
|
FirebaseCoreInternal: 091bde13e47bb1c5e9fe397634f3593dc390430f
|
||||||
FirebaseInstallations: 004915af170935e3a583faefd5f8bc851afc220f
|
FirebaseInstallations: 004915af170935e3a583faefd5f8bc851afc220f
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'package:contact/contact/model/capability_contact.dart';
|
import 'package:contact/contact/model/capability_contact.dart';
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:dartz/dartz.dart';
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:firebase_core/firebase_core.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
import 'package:forward/forward/capability_forward.dart';
|
import 'package:forward/forward/capability_forward.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
@@ -17,12 +19,15 @@ import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/c
|
|||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/tmail_autocomplete_bindings.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/presentation/bindings/tmail_autocomplete_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/bindings/email_rules_interactor_bindings.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/email_rules/bindings/email_rules_interactor_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/forward/bindings/forwarding_interactors_bindings.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/forward/bindings/forwarding_interactors_bindings.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_exception.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/model/capability_push_notification.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/model/capability_push_notification.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/presentation/firebase_bindings.dart';
|
import 'package:tmail_ui_user/features/push_notification/presentation/firebase_bindings.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart';
|
||||||
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
import 'package:tmail_ui_user/main/error/capability_validator.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
import 'package:tmail_ui_user/main/exceptions/remote_exception.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||||
|
import 'package:tmail_ui_user/main/utils/app_config.dart';
|
||||||
|
|
||||||
abstract class BaseController extends GetxController
|
abstract class BaseController extends GetxController
|
||||||
with MessageDialogActionMixin,
|
with MessageDialogActionMixin,
|
||||||
@@ -143,10 +148,16 @@ abstract class BaseController extends GetxController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void injectFirebaseBindings(Session? session, AccountId? accountId) {
|
Future<void> injectFCMBindings(Session? session, AccountId? accountId) async {
|
||||||
try {
|
try {
|
||||||
requireCapability(session!, accountId!, [capabilityPushNotification]);
|
requireCapability(session!, accountId!, [capabilityPushNotification]);
|
||||||
FireBaseBindings().dependencies();
|
if(AppConfig.appFCMAvailable) {
|
||||||
|
await dotenv.load(fileName: AppConfig.appFCMConfigurationPath);
|
||||||
|
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
||||||
|
FCMBindings().dependencies();
|
||||||
|
} else {
|
||||||
|
throw NotSupportFCMException();
|
||||||
|
}
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
logError('BaseController::injectFirebaseBindings(): exception: $e');
|
logError('BaseController::injectFirebaseBindings(): exception: $e');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/foundation.dart';
|
import 'package:flutter/foundation.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/account_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/firebase_config_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/fcm_token_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/recent_search_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/state_cache_client.dart';
|
||||||
@@ -13,7 +13,7 @@ class CachingManager {
|
|||||||
final EmailCacheClient _emailCacheClient;
|
final EmailCacheClient _emailCacheClient;
|
||||||
final RecentSearchCacheClient _recentSearchCacheClient;
|
final RecentSearchCacheClient _recentSearchCacheClient;
|
||||||
final AccountCacheClient _accountCacheClient;
|
final AccountCacheClient _accountCacheClient;
|
||||||
final FirebaseCacheClient _firebaseCacheClient;
|
final FcmTokenCacheClient _firebaseCacheClient;
|
||||||
|
|
||||||
CachingManager(
|
CachingManager(
|
||||||
this._mailboxCacheClient,
|
this._mailboxCacheClient,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import 'package:tmail_ui_user/features/mailbox/data/model/mailbox_rights_cache.d
|
|||||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
import 'package:tmail_ui_user/features/mailbox/data/model/state_cache.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
|
import 'package:tmail_ui_user/features/mailbox/data/model/state_type.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/recent_search_cache.dart';
|
import 'package:tmail_ui_user/features/mailbox_dashboard/data/model/recent_search_cache.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/data/model/email_address_hive_cache.dart';
|
import 'package:tmail_ui_user/features/thread/data/model/email_address_hive_cache.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/data/model/email_cache.dart';
|
import 'package:tmail_ui_user/features/thread/data/model/email_cache.dart';
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ class HiveCacheConfig {
|
|||||||
Hive.registerAdapter(AuthenticationInfoCacheAdapter());
|
Hive.registerAdapter(AuthenticationInfoCacheAdapter());
|
||||||
Hive.registerAdapter(RecentLoginUrlCacheAdapter());
|
Hive.registerAdapter(RecentLoginUrlCacheAdapter());
|
||||||
Hive.registerAdapter(RecentLoginUsernameCacheAdapter());
|
Hive.registerAdapter(RecentLoginUsernameCacheAdapter());
|
||||||
Hive.registerAdapter(FirebaseCacheAdapter());
|
Hive.registerAdapter(FCMTokenCacheAdapter());
|
||||||
}
|
}
|
||||||
|
|
||||||
Future closeHive() async {
|
Future closeHive() async {
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/config/hive_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||||
|
|
||||||
class FirebaseCacheClient extends HiveCacheClient<FirebaseCache> {
|
class FcmTokenCacheClient extends HiveCacheClient<FCMTokenCache> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get tableName => 'FirebaseCache';
|
String get tableName => 'FCMTokenCache';
|
||||||
}
|
}
|
||||||
@@ -13,5 +13,5 @@ class CachingConstants {
|
|||||||
static const int AUTHENTICATION_INFO_HIVE_CACHE_IDENTIFY = 11;
|
static const int AUTHENTICATION_INFO_HIVE_CACHE_IDENTIFY = 11;
|
||||||
static const int RECENT_LOGIN_URL_HIVE_CACHE_IDENTITY = 12;
|
static const int RECENT_LOGIN_URL_HIVE_CACHE_IDENTITY = 12;
|
||||||
static const int RECENT_LOGIN_USERNAME_HIVE_CACHE_IDENTITY = 13;
|
static const int RECENT_LOGIN_USERNAME_HIVE_CACHE_IDENTITY = 13;
|
||||||
static const int FIREBASE_CONFIG_CACHE_IDENTITY = 14;
|
static const int FCM_TOKEN_CACHE_IDENTITY = 14;
|
||||||
}
|
}
|
||||||
+1
-20
@@ -14,7 +14,6 @@ import 'package:jmap_dart_client/jmap/core/unsigned_int.dart';
|
|||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
import 'package:jmap_dart_client/jmap/mail/mailbox/mailbox.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
import 'package:jmap_dart_client/jmap/mail/vacation/vacation_response.dart';
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:model/model.dart';
|
import 'package:model/model.dart';
|
||||||
import 'package:package_info_plus/package_info_plus.dart';
|
import 'package:package_info_plus/package_info_plus.dart';
|
||||||
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
import 'package:pointer_interceptor/pointer_interceptor.dart';
|
||||||
@@ -65,8 +64,6 @@ import 'package:tmail_ui_user/features/manage_account/presentation/extensions/va
|
|||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/account_menu_item.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart';
|
import 'package:tmail_ui_user/features/manage_account/presentation/model/manage_account_arguments.dart';
|
||||||
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
import 'package:tmail_ui_user/features/network_status_handle/presentation/network_connnection_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/save_firebase_cache_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/presentation/notification_service.dart';
|
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/filter_message_option.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
import 'package:tmail_ui_user/features/thread/domain/model/search_query.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/domain/state/empty_trash_folder_state.dart';
|
import 'package:tmail_ui_user/features/thread/domain/state/empty_trash_folder_state.dart';
|
||||||
@@ -111,7 +108,6 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
|
|
||||||
GetAllVacationInteractor? _getAllVacationInteractor;
|
GetAllVacationInteractor? _getAllVacationInteractor;
|
||||||
UpdateVacationInteractor? _updateVacationInteractor;
|
UpdateVacationInteractor? _updateVacationInteractor;
|
||||||
SaveFirebaseCacheInteractor? _saveFirebaseCacheInteractor;
|
|
||||||
|
|
||||||
final scaffoldKey = GlobalKey<ScaffoldState>();
|
final scaffoldKey = GlobalKey<ScaffoldState>();
|
||||||
final selectedMailbox = Rxn<PresentationMailbox>();
|
final selectedMailbox = Rxn<PresentationMailbox>();
|
||||||
@@ -337,7 +333,7 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
injectAutoCompleteBindings(sessionCurrent, accountId.value);
|
injectAutoCompleteBindings(sessionCurrent, accountId.value);
|
||||||
injectRuleFilterBindings(sessionCurrent, accountId.value);
|
injectRuleFilterBindings(sessionCurrent, accountId.value);
|
||||||
injectVacationBindings(sessionCurrent, accountId.value);
|
injectVacationBindings(sessionCurrent, accountId.value);
|
||||||
injectFirebaseBindings(sessionCurrent, accountId.value);
|
injectFCMBindings(sessionCurrent, accountId.value);
|
||||||
_getVacationResponse();
|
_getVacationResponse();
|
||||||
} else {
|
} else {
|
||||||
reload();
|
reload();
|
||||||
@@ -355,21 +351,6 @@ class MailboxDashBoardController extends ReloadableController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> injectFirebaseBindings(Session? session, AccountId? accountId) async {
|
|
||||||
try {
|
|
||||||
super.injectFirebaseBindings(session, accountId);
|
|
||||||
_saveFirebaseCacheInteractor = Get.find<SaveFirebaseCacheInteractor>();
|
|
||||||
await NotificationService.initializeNotificationService();
|
|
||||||
NotificationService.onTokenRefresh.listen((token) {
|
|
||||||
_saveFirebaseCacheInteractor?.execute(FirebaseDto(token));
|
|
||||||
});
|
|
||||||
} catch (e) {
|
|
||||||
logError('MailboxDashBoardController::injectVacationBindings(): $e');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Future<void> _getAppVersion() async {
|
Future<void> _getAppVersion() async {
|
||||||
final info = await PackageInfo.fromPlatform();
|
final info = await PackageInfo.fromPlatform();
|
||||||
log('MailboxDashBoardController::_getAppVersion(): ${info.version}');
|
log('MailboxDashBoardController::_getAppVersion(): ${info.version}');
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
|
||||||
|
abstract class FCMDatasource {
|
||||||
|
Future<FCMTokenDto> getFCMToken(String accountId);
|
||||||
|
|
||||||
|
Future<void> setFCMToken(FCMTokenDto fcmToken);
|
||||||
|
|
||||||
|
Future<void> deleteFCMToken(String accountId);
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
|
|
||||||
abstract class FirebaseDatasource {
|
|
||||||
Future<FirebaseDto> getCurrentFirebase();
|
|
||||||
|
|
||||||
Future<void> setCurrentFirebase(FirebaseDto newCurrentFirebase);
|
|
||||||
|
|
||||||
Future<void> deleteCurrentFirebase(String token);
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/datasource/firebase_datasource.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/local/firebase_cache_manager.dart';
|
|
||||||
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
|
||||||
|
|
||||||
class HiveFirebaseDatasourceImpl extends FirebaseDatasource {
|
|
||||||
|
|
||||||
final FirebaseCacheManager _firebaseCacheManager;
|
|
||||||
final ExceptionThrower _exceptionThrower;
|
|
||||||
|
|
||||||
HiveFirebaseDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<FirebaseDto> getCurrentFirebase() {
|
|
||||||
return Future.sync(() async {
|
|
||||||
return await _firebaseCacheManager.getFirebase();
|
|
||||||
}).catchError((error) {
|
|
||||||
_exceptionThrower.throwException(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> setCurrentFirebase(FirebaseDto newCurrentFirebase) {
|
|
||||||
return Future.sync(() async {
|
|
||||||
return await _firebaseCacheManager.setFirebase(newCurrentFirebase);
|
|
||||||
}).catchError((error) {
|
|
||||||
_exceptionThrower.throwException(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> deleteCurrentFirebase(String token) {
|
|
||||||
return Future.sync(() async {
|
|
||||||
return await _firebaseCacheManager.deleteFirebase(token);
|
|
||||||
}).catchError((error) {
|
|
||||||
_exceptionThrower.throwException(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||||
|
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
|
||||||
|
|
||||||
|
class HiveFCMDatasourceImpl extends FCMDatasource {
|
||||||
|
|
||||||
|
final FCMCacheManager _firebaseCacheManager;
|
||||||
|
final ExceptionThrower _exceptionThrower;
|
||||||
|
|
||||||
|
HiveFCMDatasourceImpl(this._firebaseCacheManager, this._exceptionThrower);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<FCMTokenDto> getFCMToken(String accountId) {
|
||||||
|
return Future.sync(() async {
|
||||||
|
return await _firebaseCacheManager.getFCMToken(accountId);
|
||||||
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> setFCMToken(FCMTokenDto fcmToken) {
|
||||||
|
return Future.sync(() async {
|
||||||
|
return await _firebaseCacheManager.setFCMToken(fcmToken);
|
||||||
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteFCMToken(String accountId) {
|
||||||
|
return Future.sync(() async {
|
||||||
|
return await _firebaseCacheManager.deleteFCMToken(accountId);
|
||||||
|
}).catchError((error) {
|
||||||
|
_exceptionThrower.throwException(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||||
|
|
||||||
|
extension FCMCacheExtension on FCMTokenCache {
|
||||||
|
FCMTokenDto toFCMDto() {
|
||||||
|
return FCMTokenDto(
|
||||||
|
token,
|
||||||
|
accountId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/model/fcm_token_cache.dart';
|
||||||
|
|
||||||
|
extension FCMExtensions on FCMTokenDto {
|
||||||
|
FCMTokenCache toCache() {
|
||||||
|
return FCMTokenCache(
|
||||||
|
token,
|
||||||
|
accountId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
|
||||||
|
|
||||||
extension FirebaseCacheExtension on FirebaseCache {
|
|
||||||
|
|
||||||
FirebaseDto toFirebaseDto() {
|
|
||||||
return FirebaseDto(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
|
||||||
|
|
||||||
extension FirebaseExtensions on FirebaseDto {
|
|
||||||
FirebaseCache toCache() {
|
|
||||||
return FirebaseCache(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/caching/fcm_token_cache_client.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_cache_extensions.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/extensions/fcm_extensions.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/fcm_exception.dart';
|
||||||
|
|
||||||
|
class FCMCacheManager {
|
||||||
|
final FcmTokenCacheClient _fcmTokenCacheClient;
|
||||||
|
|
||||||
|
FCMCacheManager(this._fcmTokenCacheClient);
|
||||||
|
|
||||||
|
Future<FCMTokenDto> getFCMToken(String accountId) async {
|
||||||
|
try {
|
||||||
|
final firebase = await _fcmTokenCacheClient.getItem(accountId);
|
||||||
|
if(firebase != null ) {
|
||||||
|
return firebase.toFCMDto();
|
||||||
|
} else {
|
||||||
|
throw NotFoundStoredFCMException();
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
logError('FCMCacheManager::getFCM(): $e');
|
||||||
|
throw NotFoundStoredFCMException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> setFCMToken(FCMTokenDto firebaseDto) {
|
||||||
|
log('FCMCacheManager::setFCM(): $_fcmTokenCacheClient');
|
||||||
|
return _fcmTokenCacheClient.insertItem(firebaseDto.accountId, firebaseDto.toCache());
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> deleteFCMToken(String accountId) {
|
||||||
|
log('FCMCacheManager::deleteSelectedFCM(): $accountId');
|
||||||
|
return _fcmTokenCacheClient.deleteItem(accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/caching/firebase_config_cache_client.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/firebase_extensions.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/model/firebase_cache.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/extensions/firebase_cache_extensions.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/exceptions/firebase_exception.dart';
|
|
||||||
|
|
||||||
class FirebaseCacheManager {
|
|
||||||
final FirebaseCacheClient _firebaseCacheClient;
|
|
||||||
|
|
||||||
FirebaseCacheManager(this._firebaseCacheClient);
|
|
||||||
|
|
||||||
Future<FirebaseDto> getFirebase() async {
|
|
||||||
try {
|
|
||||||
final firebase = await _firebaseCacheClient.getItem(FirebaseCache.keyCacheValue);
|
|
||||||
if(firebase != null ) {
|
|
||||||
return firebase.toFirebaseDto();
|
|
||||||
} else {
|
|
||||||
throw NotFoundStoredFirebaseException();
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
logError('FirebaseCacheManager::getFirebase(): $e');
|
|
||||||
throw NotFoundStoredFirebaseException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> setFirebase(FirebaseDto firebaseDto) {
|
|
||||||
log('FirebaseCacheManager::setFirebase(): $_firebaseCacheClient');
|
|
||||||
return _firebaseCacheClient.insertItem(firebaseDto.token, firebaseDto.toCache());
|
|
||||||
}
|
|
||||||
|
|
||||||
Future<void> deleteFirebase(String token) {
|
|
||||||
log('FirebaseCacheManager::deleteSelectedFirebase(): $token');
|
|
||||||
return _firebaseCacheClient.deleteItem(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
import 'package:hive/hive.dart';
|
||||||
|
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
||||||
|
|
||||||
|
part 'fcm_token_cache.g.dart';
|
||||||
|
|
||||||
|
@HiveType(typeId: CachingConstants.FCM_TOKEN_CACHE_IDENTITY)
|
||||||
|
class FCMTokenCache extends HiveObject with EquatableMixin {
|
||||||
|
@HiveField(0)
|
||||||
|
final String token;
|
||||||
|
|
||||||
|
@HiveField(1)
|
||||||
|
final String accountId;
|
||||||
|
|
||||||
|
FCMTokenCache(
|
||||||
|
this.token,
|
||||||
|
this.accountId,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [token];
|
||||||
|
}
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
import 'package:hive/hive.dart';
|
|
||||||
import 'package:tmail_ui_user/features/caching/utils/caching_constants.dart';
|
|
||||||
|
|
||||||
part 'firebase_cache.g.dart';
|
|
||||||
|
|
||||||
@HiveType(typeId: CachingConstants.FIREBASE_CONFIG_CACHE_IDENTITY)
|
|
||||||
class FirebaseCache extends HiveObject with EquatableMixin {
|
|
||||||
|
|
||||||
static const String keyCacheValue = 'firebaseCache';
|
|
||||||
|
|
||||||
@HiveField(0)
|
|
||||||
final String token;
|
|
||||||
|
|
||||||
FirebaseCache(this.token);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [token];
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
import 'package:core/utils/app_logger.dart';
|
||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
|
|
||||||
|
class FCMRepositoryImpl extends FCMRepository {
|
||||||
|
|
||||||
|
final FCMDatasource _fcmDatasource;
|
||||||
|
|
||||||
|
FCMRepositoryImpl(this._fcmDatasource);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<FCMTokenDto> getFCMToken(String accountId) {
|
||||||
|
return _fcmDatasource.getFCMToken(accountId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> setFCMToken(FCMTokenDto fcmTokenDto) {
|
||||||
|
log('FCMRepositoryImpl::setCurrentFCM(): $fcmTokenDto');
|
||||||
|
return _fcmDatasource.setFCMToken(fcmTokenDto);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Future<void> deleteFCMToken(String accountId) {
|
||||||
|
return _fcmDatasource.deleteFCMToken(accountId);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/datasource/firebase_datasource.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/firebase_repository.dart';
|
|
||||||
|
|
||||||
class FirebaseRepositoryImpl extends FirebaseRepository {
|
|
||||||
|
|
||||||
final FirebaseDatasource _firebaseDatasource;
|
|
||||||
|
|
||||||
FirebaseRepositoryImpl(this._firebaseDatasource);
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<FirebaseDto> getCurrentFirebase() {
|
|
||||||
return _firebaseDatasource.getCurrentFirebase();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> setCurrentFirebase(FirebaseDto newCurrentFirebase) {
|
|
||||||
log('FirebaseRepositoryImpl::setCurrentFirebase(): $newCurrentFirebase');
|
|
||||||
return _firebaseDatasource.setCurrentFirebase(newCurrentFirebase);
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Future<void> deleteCurrentFirebase(String token) {
|
|
||||||
return _firebaseDatasource.deleteCurrentFirebase(token);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
class NotFoundStoredFCMException implements Exception {}
|
||||||
|
|
||||||
|
class NotSupportFCMException implements Exception {}
|
||||||
|
|
||||||
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
class NotFoundStoredFirebaseException implements Exception {}
|
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
|
||||||
|
abstract class FCMRepository {
|
||||||
|
Future<FCMTokenDto> getFCMToken(String accountId);
|
||||||
|
|
||||||
|
Future<void> setFCMToken(FCMTokenDto fcmTokenDto);
|
||||||
|
|
||||||
|
Future<void> deleteFCMToken(String accountId);
|
||||||
|
}
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
|
|
||||||
abstract class FirebaseRepository {
|
|
||||||
Future<FirebaseDto> getCurrentFirebase();
|
|
||||||
|
|
||||||
Future<void> setCurrentFirebase(FirebaseDto newCurrentFirebase);
|
|
||||||
|
|
||||||
Future<void> deleteCurrentFirebase(String token);
|
|
||||||
}
|
|
||||||
+4
-4
@@ -1,18 +1,18 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
|
|
||||||
class DeleteFirebaseSuccess extends UIState {
|
class DeleteFCMTokenSuccess extends UIState {
|
||||||
|
|
||||||
|
|
||||||
DeleteFirebaseSuccess();
|
DeleteFCMTokenSuccess();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class DeleteFirebaseFailure extends FeatureFailure {
|
class DeleteFCMTokenFailure extends FeatureFailure {
|
||||||
final dynamic exception;
|
final dynamic exception;
|
||||||
|
|
||||||
DeleteFirebaseFailure(this.exception);
|
DeleteFCMTokenFailure(this.exception);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [exception];
|
List<Object> get props => [exception];
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
|
||||||
|
class GetFCMTokenSuccess extends UIState {
|
||||||
|
|
||||||
|
final FCMTokenDto firebaseDto;
|
||||||
|
|
||||||
|
GetFCMTokenSuccess(this.firebaseDto);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [firebaseDto];
|
||||||
|
}
|
||||||
|
|
||||||
|
class GetFCMTokenFailure extends FeatureFailure {
|
||||||
|
final dynamic exception;
|
||||||
|
|
||||||
|
GetFCMTokenFailure(this.exception);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object> get props => [exception];
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import 'package:core/core.dart';
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
|
|
||||||
class GetFirebaseSuccess extends UIState {
|
|
||||||
|
|
||||||
final FirebaseDto firebaseDto;
|
|
||||||
|
|
||||||
GetFirebaseSuccess(this.firebaseDto);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [firebaseDto];
|
|
||||||
}
|
|
||||||
|
|
||||||
class GetFirebaseFailure extends FeatureFailure {
|
|
||||||
final dynamic exception;
|
|
||||||
|
|
||||||
GetFirebaseFailure(this.exception);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object> get props => [exception];
|
|
||||||
}
|
|
||||||
+4
-4
@@ -1,18 +1,18 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
|
|
||||||
class SaveFirebaseSuccess extends UIState {
|
class SaveFCMTokenSuccess extends UIState {
|
||||||
|
|
||||||
|
|
||||||
SaveFirebaseSuccess();
|
SaveFCMTokenSuccess();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [];
|
List<Object> get props => [];
|
||||||
}
|
}
|
||||||
|
|
||||||
class SaveFirebaseFailure extends FeatureFailure {
|
class SaveFCMTokenFailure extends FeatureFailure {
|
||||||
final dynamic exception;
|
final dynamic exception;
|
||||||
|
|
||||||
SaveFirebaseFailure(this.exception);
|
SaveFCMTokenFailure(this.exception);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
List<Object> get props => [exception];
|
List<Object> get props => [exception];
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/state/delete_fcm_token_state.dart';
|
||||||
|
|
||||||
|
class DeleteFCMTokenCacheInteractor {
|
||||||
|
final FCMRepository _fcmRepository;
|
||||||
|
|
||||||
|
DeleteFCMTokenCacheInteractor(this._fcmRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(String accountId) async* {
|
||||||
|
try {
|
||||||
|
await _fcmRepository.deleteFCMToken(accountId);
|
||||||
|
yield Right<Failure, Success>(DeleteFCMTokenSuccess());
|
||||||
|
} catch (e) {
|
||||||
|
logError('DeleteFirebaseCacheInteractor::execute(): $e');
|
||||||
|
yield Left<Failure, Success>(DeleteFCMTokenFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
import 'package:core/core.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/firebase_repository.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/state/delete_firebase_state.dart';
|
|
||||||
|
|
||||||
class DeleteFirebaseCacheInteractor {
|
|
||||||
final FirebaseRepository _firebaseRepository;
|
|
||||||
|
|
||||||
DeleteFirebaseCacheInteractor(this._firebaseRepository);
|
|
||||||
|
|
||||||
Future<Either<Failure, Success>> execute(String token) async {
|
|
||||||
try {
|
|
||||||
await _firebaseRepository.deleteCurrentFirebase(token);
|
|
||||||
return Right<Failure, Success>(DeleteFirebaseSuccess());
|
|
||||||
} catch (e) {
|
|
||||||
logError('DeleteFirebaseCacheInteractor::execute(): $e');
|
|
||||||
return Left<Failure, Success>(DeleteFirebaseFailure(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
|
||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/state/get_fcm_token_state.dart';
|
||||||
|
|
||||||
|
class GetFCMTokenCacheInteractor {
|
||||||
|
|
||||||
|
final FCMRepository _fcmRepository;
|
||||||
|
|
||||||
|
GetFCMTokenCacheInteractor(this._fcmRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(
|
||||||
|
String accountId) async* {
|
||||||
|
try {
|
||||||
|
final fcmToken = await _fcmRepository.getFCMToken(accountId);
|
||||||
|
yield Right<Failure, Success>(GetFCMTokenSuccess(fcmToken));
|
||||||
|
} catch (e) {
|
||||||
|
logError('GetFirebaseCacheInteractor::execute(): $e');
|
||||||
|
yield Left<Failure, Success>(GetFCMTokenFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
|
|
||||||
import 'package:core/core.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:model/model.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/firebase_repository.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/state/get_firebase_state.dart';
|
|
||||||
|
|
||||||
class GetFirebaseCacheInteractor {
|
|
||||||
|
|
||||||
final FirebaseRepository _firebaseRepository;
|
|
||||||
|
|
||||||
GetFirebaseCacheInteractor(this._firebaseRepository);
|
|
||||||
|
|
||||||
Future<Either<Failure, Success>> execute(
|
|
||||||
OIDCConfiguration config,
|
|
||||||
String refreshToken) async {
|
|
||||||
try {
|
|
||||||
final firebase = await _firebaseRepository.getCurrentFirebase();
|
|
||||||
return Right<Failure, Success>(GetFirebaseSuccess(firebase));
|
|
||||||
} catch (e) {
|
|
||||||
logError('GetFirebaseCacheInteractor::execute(): $e');
|
|
||||||
return Left<Failure, Success>(GetFirebaseFailure(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import 'package:core/core.dart';
|
||||||
|
import 'package:dartz/dartz.dart';
|
||||||
|
import 'package:model/fcm/fcm_token_dto.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
|
import 'package:tmail_ui_user/features/push_notification/domain/state/save_fcm_token_state.dart';
|
||||||
|
|
||||||
|
class SaveFCMTokenCacheInteractor {
|
||||||
|
final FCMRepository _fcmRepository;
|
||||||
|
|
||||||
|
SaveFCMTokenCacheInteractor(this._fcmRepository);
|
||||||
|
|
||||||
|
Stream<Either<Failure, Success>> execute(FCMTokenDto fcmTokenDto) async* {
|
||||||
|
try {
|
||||||
|
await _fcmRepository.setFCMToken(fcmTokenDto);
|
||||||
|
yield Right<Failure, Success>(SaveFCMTokenSuccess());
|
||||||
|
} catch (e) {
|
||||||
|
logError('SaveFirebaseCacheInteractor::execute(): $e');
|
||||||
|
yield Left<Failure, Success>(SaveFCMTokenFailure(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
import 'package:core/core.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/firebase_repository.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/state/save_firebase_state.dart';
|
|
||||||
|
|
||||||
class SaveFirebaseCacheInteractor {
|
|
||||||
final FirebaseRepository _firebaseRepository;
|
|
||||||
|
|
||||||
SaveFirebaseCacheInteractor(this._firebaseRepository);
|
|
||||||
|
|
||||||
Future<Either<Failure, Success>> execute(FirebaseDto firebaseDto) async {
|
|
||||||
try {
|
|
||||||
await _firebaseRepository.setCurrentFirebase(firebaseDto);
|
|
||||||
return Right<Failure, Success>(SaveFirebaseSuccess());
|
|
||||||
} catch (e) {
|
|
||||||
logError('SaveFirebaseCacheInteractor::execute(): $e');
|
|
||||||
return Left<Failure, Success>(SaveFirebaseFailure(e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,46 +1,46 @@
|
|||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
import 'package:tmail_ui_user/features/base/base_bindings.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/datasource/firebase_datasource.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/datasource/fcm_datasource.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/datasource_impl/hive_account_datasource_impl.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/datasource_impl/hive_fcm_datasource_impl.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/local/firebase_cache_manager.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/repository/firebase_repository_impl.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/repository/fcm_repository_impl.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/repository/firebase_repository.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/repository/fcm_repository.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_firebase_cache_interactor.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/usecases/delete_fcm_token_cache_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_firebase_cache_interactor.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/usecases/get_fcm_token_cache_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/save_firebase_cache_interactor.dart';
|
import 'package:tmail_ui_user/features/push_notification/domain/usecases/save_fcm_token_cache_interactor.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
|
|
||||||
class FireBaseBindings extends BaseBindings {
|
class FCMBindings extends BaseBindings {
|
||||||
@override
|
@override
|
||||||
void bindingsController() {}
|
void bindingsController() {}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsDataSource() {
|
void bindingsDataSource() {
|
||||||
Get.put<FirebaseDatasource>(Get.find<HiveFirebaseDatasourceImpl>());
|
Get.put<FCMDatasource>(Get.find<HiveFCMDatasourceImpl>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsDataSourceImpl() {
|
void bindingsDataSourceImpl() {
|
||||||
Get.put(HiveFirebaseDatasourceImpl(
|
Get.put(HiveFCMDatasourceImpl(
|
||||||
Get.find<FirebaseCacheManager>(),
|
Get.find<FCMCacheManager>(),
|
||||||
Get.find<CacheExceptionThrower>(),
|
Get.find<CacheExceptionThrower>(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsInteractor() {
|
void bindingsInteractor() {
|
||||||
Get.put(DeleteFirebaseCacheInteractor(Get.find<FirebaseRepositoryImpl>()));
|
Get.put(DeleteFCMTokenCacheInteractor(Get.find<FCMRepositoryImpl>()));
|
||||||
Get.put(SaveFirebaseCacheInteractor(Get.find<FirebaseRepositoryImpl>()));
|
Get.put(SaveFCMTokenCacheInteractor(Get.find<FCMRepositoryImpl>()));
|
||||||
Get.put(GetFirebaseCacheInteractor(Get.find<FirebaseRepositoryImpl>()));
|
Get.put(GetFCMTokenCacheInteractor(Get.find<FCMRepositoryImpl>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsRepository() {
|
void bindingsRepository() {
|
||||||
Get.put<FirebaseRepository>(Get.find<FirebaseRepositoryImpl>());
|
Get.put<FCMRepository>(Get.find<FCMRepositoryImpl>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void bindingsRepositoryImpl() {
|
void bindingsRepositoryImpl() {
|
||||||
Get.put(FirebaseRepositoryImpl(Get.find<FirebaseDatasource>()));
|
Get.put(FCMRepositoryImpl(Get.find<FCMDatasource>()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:core/utils/app_logger.dart';
|
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
|
||||||
import 'package:firebase_messaging/firebase_messaging.dart';
|
|
||||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
||||||
import 'package:get/get.dart';
|
|
||||||
import 'package:model/firebase/firebase_dto.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/domain/usecases/save_firebase_cache_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart';
|
|
||||||
|
|
||||||
@pragma('vm:entry-point')
|
|
||||||
Future<void> firebaseMessagingBackgroundHandler(RemoteMessage message) async {
|
|
||||||
await dotenv.load(fileName: 'env.file');
|
|
||||||
try {
|
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
||||||
} catch (e) {
|
|
||||||
log('NotificationService::initializeNotificationService(): $e');
|
|
||||||
}
|
|
||||||
log('firebaseMessagingBackgroundHandler: ${message.data}');
|
|
||||||
}
|
|
||||||
|
|
||||||
class NotificationService {
|
|
||||||
factory NotificationService() => _instance;
|
|
||||||
|
|
||||||
NotificationService._internal();
|
|
||||||
|
|
||||||
static final NotificationService _instance = NotificationService._internal();
|
|
||||||
|
|
||||||
static get _firebaseMessaging => FirebaseMessaging.instance;
|
|
||||||
|
|
||||||
static Stream<String> get onTokenRefresh => _firebaseMessaging.onTokenRefresh;
|
|
||||||
static bool _isFlutterLocalNotificationsInitialized = false;
|
|
||||||
|
|
||||||
static Future<void> initializeNotificationService() async {
|
|
||||||
try {
|
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
||||||
} catch (e) {
|
|
||||||
log('NotificationService::initializeNotificationService(): $e');
|
|
||||||
}
|
|
||||||
FirebaseMessaging.onBackgroundMessage(firebaseMessagingBackgroundHandler);
|
|
||||||
if (_isFlutterLocalNotificationsInitialized) return;
|
|
||||||
final _saveFirebaseCacheInteractor = Get.find<SaveFirebaseCacheInteractor>();
|
|
||||||
final token = await _firebaseMessaging.getToken();
|
|
||||||
_saveFirebaseCacheInteractor.execute(FirebaseDto(token));
|
|
||||||
await _initFirebaseMessaging();
|
|
||||||
_isFlutterLocalNotificationsInitialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> _initFirebaseMessaging() async {
|
|
||||||
FirebaseMessaging.onMessage.listen(_handleIncomingForegroundNotification);
|
|
||||||
FirebaseMessaging.onMessageOpenedApp.listen(_handleOpenedAppNotification);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Future<void> _handleIncomingForegroundNotification(
|
|
||||||
RemoteMessage remoteMessage,
|
|
||||||
) async {
|
|
||||||
log('firebaseMessagingForegroundHandler: ${remoteMessage.data}');
|
|
||||||
}
|
|
||||||
|
|
||||||
static void _handleOpenedAppNotification(RemoteMessage remoteMessage) {}
|
|
||||||
|
|
||||||
|
|
||||||
static Future<void> deleteToken() async => _firebaseMessaging.deleteToken();
|
|
||||||
}
|
|
||||||
+2
-3
@@ -1,11 +1,10 @@
|
|||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:firebase_core/firebase_core.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
import 'package:tmail_ui_user/features/caching/config/hive_cache_config.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/presentation/firebase_options.dart';
|
|
||||||
import 'package:tmail_ui_user/main/bindings/main_bindings.dart';
|
import 'package:tmail_ui_user/main/bindings/main_bindings.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||||
import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart';
|
import 'package:tmail_ui_user/main/localizations/app_localizations_delegate.dart';
|
||||||
@@ -15,7 +14,6 @@ import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
|||||||
import 'package:worker_manager/worker_manager.dart';
|
import 'package:worker_manager/worker_manager.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
|
|
||||||
initLogger(() async {
|
initLogger(() async {
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
SystemChrome.setSystemUIOverlayStyle(const SystemUiOverlayStyle(
|
||||||
@@ -28,6 +26,7 @@ void main() async {
|
|||||||
await HiveCacheConfig().setUp();
|
await HiveCacheConfig().setUp();
|
||||||
await HiveCacheConfig.initializeEncryptionKey();
|
await HiveCacheConfig.initializeEncryptionKey();
|
||||||
await Executor().warmUp();
|
await Executor().warmUp();
|
||||||
|
await dotenv.load(fileName: 'env.file');
|
||||||
runApp(const TMailApp());
|
runApp(const TMailApp());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import 'package:tmail_ui_user/features/caching/authentication_info_cache_client.
|
|||||||
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/email_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/encryption_key_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/encryption_key_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/firebase_config_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/fcm_token_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/mailbox_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/recent_login_url_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/recent_login_url_cache_client.dart';
|
||||||
import 'package:tmail_ui_user/features/caching/recent_login_username_cache_client.dart';
|
import 'package:tmail_ui_user/features/caching/recent_login_username_cache_client.dart';
|
||||||
@@ -23,7 +23,7 @@ import 'package:tmail_ui_user/features/login/data/local/oidc_configuration_cache
|
|||||||
import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart';
|
import 'package:tmail_ui_user/features/login/data/local/token_oidc_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart';
|
import 'package:tmail_ui_user/features/mailbox/data/local/mailbox_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_manager.dart';
|
import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/push_notification/data/local/firebase_cache_manager.dart';
|
import 'package:tmail_ui_user/features/push_notification/data/local/fcm_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
|
import 'package:tmail_ui_user/features/thread/data/local/email_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||||
|
|
||||||
@@ -57,15 +57,15 @@ class LocalBindings extends Bindings {
|
|||||||
Get.put(RecentLoginUrlCacheManager((Get.find<RecentLoginUrlCacheClient>())));
|
Get.put(RecentLoginUrlCacheManager((Get.find<RecentLoginUrlCacheClient>())));
|
||||||
Get.put(RecentLoginUsernameCacheClient());
|
Get.put(RecentLoginUsernameCacheClient());
|
||||||
Get.put(RecentLoginUsernameCacheManager(Get.find<RecentLoginUsernameCacheClient>()));
|
Get.put(RecentLoginUsernameCacheManager(Get.find<RecentLoginUsernameCacheClient>()));
|
||||||
Get.put(FirebaseCacheClient());
|
Get.put(FcmTokenCacheClient());
|
||||||
Get.put(FirebaseCacheManager(Get.find<FirebaseCacheClient>()));
|
Get.put(FCMCacheManager(Get.find<FcmTokenCacheClient>()));
|
||||||
Get.put(CachingManager(
|
Get.put(CachingManager(
|
||||||
Get.find<MailboxCacheClient>(),
|
Get.find<MailboxCacheClient>(),
|
||||||
Get.find<StateCacheClient>(),
|
Get.find<StateCacheClient>(),
|
||||||
Get.find<EmailCacheClient>(),
|
Get.find<EmailCacheClient>(),
|
||||||
Get.find<RecentSearchCacheClient>(),
|
Get.find<RecentSearchCacheClient>(),
|
||||||
Get.find<AccountCacheClient>(),
|
Get.find<AccountCacheClient>(),
|
||||||
Get.find<FirebaseCacheClient>(),
|
Get.find<FcmTokenCacheClient>(),
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,4 +12,13 @@ class AppConfig {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
static String appDashboardConfigurationPath = "configurations/app_dashboard.json";
|
static String appDashboardConfigurationPath = "configurations/app_dashboard.json";
|
||||||
|
static bool get appFCMAvailable {
|
||||||
|
final supported = dotenv.get('FCM_AVAILABLE', fallback: 'unsupported');
|
||||||
|
if (supported == 'supported') {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
static String appFCMConfigurationPath = "configurations/env.fcm";
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
import 'package:equatable/equatable.dart';
|
||||||
|
|
||||||
|
class FCMTokenDto with EquatableMixin {
|
||||||
|
final String token;
|
||||||
|
final String accountId;
|
||||||
|
|
||||||
|
FCMTokenDto(
|
||||||
|
this.token,
|
||||||
|
this.accountId,
|
||||||
|
);
|
||||||
|
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [
|
||||||
|
token,
|
||||||
|
accountId,
|
||||||
|
];
|
||||||
|
}
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
import 'package:equatable/equatable.dart';
|
|
||||||
|
|
||||||
class FirebaseDto with EquatableMixin {
|
|
||||||
final String token;
|
|
||||||
|
|
||||||
FirebaseDto(this.token);
|
|
||||||
|
|
||||||
@override
|
|
||||||
List<Object?> get props => [token];
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user