@@ -19,6 +19,7 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
1919 private let onboardingCheckUseCase : OnboardingCheckUseCase
2020 private let markOnboardingSeenUseCase : MarkOnboardingSeenUseCase
2121 private let appVersionUseCase : AppVersionUseCase
22+ private let fetchRemoteAppVersionUseCase : FetchRemoteAppVersionUseCase
2223 private let syncFCMTokenUseCase : SyncFCMTokenUseCase
2324 private var cancellable : Set < AnyCancellable > = [ ]
2425
@@ -28,13 +29,15 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
2829 onboardingCheckUseCase: OnboardingCheckUseCase ,
2930 markOnboardingSeenUseCase: MarkOnboardingSeenUseCase ,
3031 appVersionUseCase: AppVersionUseCase ,
32+ fetchRemoteAppVersionUseCase: FetchRemoteAppVersionUseCase ,
3133 syncFCMTokenUseCase: SyncFCMTokenUseCase
3234 ) {
3335 self . navigationController = navigationController
3436 self . authStateUseCase = authStateUseCase
3537 self . onboardingCheckUseCase = onboardingCheckUseCase
3638 self . markOnboardingSeenUseCase = markOnboardingSeenUseCase
3739 self . appVersionUseCase = appVersionUseCase
40+ self . fetchRemoteAppVersionUseCase = fetchRemoteAppVersionUseCase
3841 self . syncFCMTokenUseCase = syncFCMTokenUseCase
3942 }
4043
@@ -67,25 +70,34 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
6770 private func checkAppUpdate( ) {
6871 Publishers . Zip (
6972 appVersionUseCase. execute ( ) . setFailureType ( to: Error . self) ,
70- appVersionUseCase . executeRecentVersion ( )
73+ fetchRemoteAppVersionUseCase . execute ( )
7174 )
7275 . receive ( on: DispatchQueue . main)
7376 . sink ( receiveCompletion: { [ weak self] completion in
7477 if case . failure = completion {
7578 self ? . proceedWithAppFlow ( )
7679 }
77- } , receiveValue: { [ weak self] currentVersionString, latestVersionString in
80+ } , receiveValue: { [ weak self] currentVersionString, remoteVersions in
7881 guard let self = self ,
7982 let currentVersion = Version ( currentVersionString) ,
80- let latestVersion = Version ( latestVersionString)
83+ let minimumVersion = Version ( remoteVersions. minimumRequiredVersion) ,
84+ let latestVersion = Version ( remoteVersions. latestVersion)
8185 else {
8286 self ? . proceedWithAppFlow ( )
8387 return
8488 }
8589
86- if currentVersion. isMajorOrMinorUpdateRequired ( from: latestVersion) {
87- self . presentUpdateSheet ( )
88- } else {
90+ Log . debug ( " currentVersionString: \( currentVersionString) " , logger: AppLogger . ui)
91+ Log . debug ( " minimumRequiredVersion: \( remoteVersions. minimumRequiredVersion) " , logger: AppLogger . ui)
92+ Log . debug ( " latestVersion: \( remoteVersions. latestVersion) " , logger: AppLogger . ui)
93+
94+ if currentVersion < minimumVersion {
95+ self . presentUpdateSheet ( ) // 강업
96+ }
97+ else if currentVersion < latestVersion {
98+ self . presentUpdateSheet ( isForced: false ) // 권장
99+ }
100+ else {
89101 self . proceedWithAppFlow ( )
90102 }
91103 } )
@@ -203,21 +215,41 @@ public final class AppCoordinator: Coordinator, AuthenticationRequiredNotifying,
203215 . store ( in: & cancellable)
204216 }
205217
206- private func presentUpdateSheet( ) {
207- let dialog = BKDialog (
208- title: " 최신 버전이 출시되었습니다 " ,
209- subtitle: " 최적의 사용 환경을 위해 업데이트해주세요. " ,
210- config: . init(
211- leftButtonTitle: " 업데이트 하기 " ,
212- leftButtonAction: AppStoreLinker . openAppStore
218+ private func presentUpdateSheet( isForced: Bool = true ) {
219+ var dialog : BKDialog ?
220+
221+ if isForced {
222+ dialog = BKDialog (
223+ title: " 최신 버전이 출시되었습니다 " ,
224+ subtitle: " 최적의 사용 환경을 위해 업데이트해주세요. " ,
225+ config: . init(
226+ leftButtonTitle: " 업데이트 하기 " ,
227+ leftButtonAction: AppStoreLinker . openAppStore
228+ )
213229 )
214- )
215-
230+ } else {
231+ // TODO(dyk) : 디자인 파트와 논의 후 subtitle 수정하기
232+ dialog = BKDialog (
233+ title: " 최신 버전이 출시되었습니다 " ,
234+ subtitle: " 최적의 사용 환경을 위해 업데이트해주세요. " ,
235+ config: . init(
236+ leftButtonTitle: " 업데이트 하기 " ,
237+ leftButtonAction: AppStoreLinker . openAppStore,
238+ rightButtonTitle: " 나중에 하기 " ,
239+ rightButtonAction: { [ weak self] in
240+ guard let self else { return }
241+ self . navigationController. dismiss ( animated: true ) {
242+ self . proceedWithAppFlow ( )
243+ }
244+ }
245+ )
246+ )
247+ }
248+
249+ guard let dialog else { return }
216250 let dialogViewController = BKDialogViewController ( dialog: dialog)
217251 dialogViewController. isModalInPresentation = true
218- DispatchQueue . main. async {
219- self . navigationController. present ( dialogViewController, animated: true )
220- }
252+ navigationController. present ( dialogViewController, animated: true )
221253 }
222254
223255 private func requestNotificationPermissionIfNeeded( ) {
0 commit comments