TF-439 Implement handle register new token when expired

This commit is contained in:
dab246
2022-11-29 16:24:04 +07:00
committed by Dat H. Pham
parent 92da2d5152
commit d5e093150f
10 changed files with 166 additions and 7 deletions
@@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
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/network/fcm_api.dart';
import 'package:tmail_ui_user/features/push_notification/domain/model/register_new_token_request.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class FcmDatasourceImpl extends FCMDatasource {
@@ -56,4 +57,13 @@ class FcmDatasourceImpl extends FCMDatasource {
Future<bool> storeStateToRefresh(TypeName typeName, jmap.State newState) {
throw UnimplementedError();
}
@override
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest newTokenRequest) {
return Future.sync(() async {
return await _fcmApi.registerNewToken(newTokenRequest);
}).catchError((error) {
_exceptionThrower.throwException(error);
});
}
}
@@ -4,6 +4,7 @@ import 'package:jmap_dart_client/jmap/core/state.dart' as jmap;
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/features/push_notification/domain/model/register_new_token_request.dart';
import 'package:tmail_ui_user/main/exceptions/exception_thrower.dart';
class HiveFCMDatasourceImpl extends FCMDatasource {
@@ -80,4 +81,9 @@ class HiveFCMDatasourceImpl extends FCMDatasource {
Future<FirebaseSubscription> getFirebaseSubscriptionByDeviceId(String deviceId) {
throw UnimplementedError();
}
@override
Future<FirebaseSubscription> registerNewToken(RegisterNewTokenRequest registerNewTokenRequest) {
throw UnimplementedError();
}
}