TF-439 Implement handle store device id

This commit is contained in:
dab246
2022-11-29 14:50:51 +07:00
committed by Dat H. Pham
parent 5103f5a94c
commit 21ec4bb071
10 changed files with 145 additions and 3 deletions
@@ -65,4 +65,13 @@ class HiveFCMDatasourceImpl extends FCMDatasource {
_exceptionThrower.throwException(error);
});
}
@override
Future<bool> storeDeviceId(String deviceId) {
return Future.sync(() async {
return await _firebaseCacheManager.storeDeviceId(deviceId);
}).catchError((error) {
_exceptionThrower.throwException(error);
});
}
}
@@ -12,6 +12,8 @@ class FCMCacheManager {
final FcmTokenCacheClient _fcmTokenCacheClient;
final SharedPreferences _sharedPreferences;
static const String fcmDeviceIdKey = 'FCM_DEVICE_ID';
FCMCacheManager(this._fcmTokenCacheClient, this._sharedPreferences);
Future<FCMTokenDto> getFCMToken(String accountId) async {
@@ -69,4 +71,8 @@ class FCMCacheManager {
_sharedPreferences.remove(TypeName.emailDelivery.value)
]).then((listResult) => listResult.every((result) => result));
}
Future<bool> storeDeviceId(String deviceId) {
return _sharedPreferences.setString(fcmDeviceIdKey, deviceId);
}
}
@@ -88,4 +88,9 @@ class FCMRepositoryImpl extends FCMRepository {
Future<bool> deleteStateToRefresh(TypeName typeName) {
return _fcmDatasource.deleteStateToRefresh(typeName);
}
@override
Future<bool> storeDeviceId(String deviceId) {
return _fcmDatasource.storeDeviceId(deviceId);
}
}