diff --git a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt index 4dee6a5e0..5708b4c7a 100644 --- a/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt +++ b/android/festago/app/src/main/java/com/festago/festago/data/repository/AuthDefaultRepository.kt @@ -4,12 +4,15 @@ import com.festago.festago.data.service.UserRetrofitService import com.festago.festago.data.util.runCatchingWithErrorHandler import com.festago.festago.repository.AuthRepository import com.festago.festago.repository.TokenRepository +import com.google.firebase.messaging.FirebaseMessaging import com.kakao.sdk.user.UserApiClient +import kotlinx.coroutines.tasks.await import javax.inject.Inject class AuthDefaultRepository @Inject constructor( private val userRetrofitService: UserRetrofitService, private val tokenRepository: TokenRepository, + private val firebaseMessaging: FirebaseMessaging, ) : AuthRepository { override val isSigned: Boolean @@ -18,7 +21,8 @@ class AuthDefaultRepository @Inject constructor( override val token: String? get() = tokenRepository.token - override suspend fun signIn(socialType: String, token: String, fcmToken: String): Result { + override suspend fun signIn(socialType: String, token: String): Result { + val fcmToken = firebaseMessaging.token.await() return tokenRepository.signIn(socialType, token, fcmToken) } diff --git a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt index a3e632370..cb2aba5eb 100644 --- a/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt +++ b/android/festago/app/src/main/java/com/festago/festago/presentation/ui/signin/SignInViewModel.kt @@ -7,17 +7,14 @@ import com.festago.festago.analytics.logNetworkFailure import com.festago.festago.presentation.util.MutableSingleLiveData import com.festago.festago.presentation.util.SingleLiveData import com.festago.festago.repository.AuthRepository -import com.google.firebase.messaging.FirebaseMessaging import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.CoroutineExceptionHandler import kotlinx.coroutines.launch -import kotlinx.coroutines.tasks.await import javax.inject.Inject @HiltViewModel class SignInViewModel @Inject constructor( private val authRepository: AuthRepository, - private val firebaseMessaging: FirebaseMessaging, private val analyticsHelper: AnalyticsHelper, ) : ViewModel() { @@ -36,17 +33,13 @@ class SignInViewModel @Inject constructor( fun signIn(token: String) { viewModelScope.launch(exceptionHandler) { - val fcmToken = firebaseMessaging.token.await() - authRepository.signIn( - SOCIAL_TYPE_KAKAO, - token, - fcmToken, - ).onSuccess { - _event.setValue(SignInEvent.SignInSuccess) - }.onFailure { - _event.setValue(SignInEvent.SignInFailure) - analyticsHelper.logNetworkFailure(KEY_SIGN_IN_LOG, it.message.toString()) - } + authRepository.signIn(SOCIAL_TYPE_KAKAO, token) + .onSuccess { + _event.setValue(SignInEvent.SignInSuccess) + }.onFailure { + _event.setValue(SignInEvent.SignInFailure) + analyticsHelper.logNetworkFailure(KEY_SIGN_IN_LOG, it.message.toString()) + } } } diff --git a/android/festago/domain/src/main/java/com/festago/festago/repository/AuthRepository.kt b/android/festago/domain/src/main/java/com/festago/festago/repository/AuthRepository.kt index e852fcddc..1ce24a7df 100644 --- a/android/festago/domain/src/main/java/com/festago/festago/repository/AuthRepository.kt +++ b/android/festago/domain/src/main/java/com/festago/festago/repository/AuthRepository.kt @@ -3,7 +3,7 @@ package com.festago.festago.repository interface AuthRepository { val isSigned: Boolean val token: String? - suspend fun signIn(socialType: String, token: String, fcmToken: String): Result + suspend fun signIn(socialType: String, token: String): Result suspend fun signOut(): Result suspend fun deleteAccount(): Result }