Skip to content

Commit 9c4ecba

Browse files
committed
feat: 업데이트 로직 추가
1 parent c3f1319 commit 9c4ecba

3 files changed

Lines changed: 30 additions & 11 deletions

File tree

Projects/Presentation/Sources/Setting/View/SettingView.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,14 @@ final class SettingView: BaseViewController<SettingViewModel> {
170170

171171
viewModel.output.urlPublisher
172172
.receive(on: DispatchQueue.main)
173-
.sink(receiveValue: { [weak self] url in
174-
guard let url else { return }
175-
176-
let safariView = SFSafariViewController(url: url)
177-
self?.present(safariView, animated: true)
173+
.sink(receiveValue: { [weak self] urlType in
174+
switch urlType {
175+
case .internal(let url):
176+
let safariView = SFSafariViewController(url: url)
177+
self?.present(safariView, animated: true)
178+
case .external(let url):
179+
UIApplication.shared.open(url, options: [:], completionHandler: nil)
180+
}
178181
})
179182
.store(in: &cancellables)
180183

Projects/Presentation/Sources/Setting/ViewModel/SettingViewModel.swift

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@ import Foundation
1111

1212
final class SettingViewModel: ViewModel {
1313
enum URLType {
14+
case update
1415
case terms
1516
case privacy
1617

1718
fileprivate var url: URL? {
1819
switch self {
20+
case .update:
21+
return URL(string: "itms-apps://itunes.apple.com/app/{빛나길 id}")
1922
case .terms:
2023
return URL(string: "https://complex-wombat-99f.notion.site/2025-7-20-236f4587491d8071833adfaf8115bce2")
2124
case .privacy:
@@ -24,6 +27,11 @@ final class SettingViewModel: ViewModel {
2427
}
2528
}
2629

30+
enum OpenURLType {
31+
case `internal`(url: URL)
32+
case external(url: URL)
33+
}
34+
2735
enum VersionType {
2836
case needUpdate(version: String)
2937
case latest(version: String)
@@ -43,15 +51,15 @@ final class SettingViewModel: ViewModel {
4351
let generalNotificationEnabled: AnyPublisher<Bool, Never>
4452
let pushNotificationEnabled: AnyPublisher<Bool, Never>
4553
let versionPublisher: AnyPublisher<VersionType, Never>
46-
let urlPublisher: AnyPublisher<URL?, Never>
54+
let urlPublisher: AnyPublisher<OpenURLType, Never>
4755
let isAuthenticatedPublisher: AnyPublisher<Bool, Never>
4856
}
4957

5058
private(set) var output: Output
5159
private let versionSubject = PassthroughSubject<VersionType, Never>()
5260
private let generalNoticeEnabledSubject = CurrentValueSubject<Bool, Never>(false)
5361
private let pushNoticeEnabledSubject = CurrentValueSubject<Bool, Never>(true)
54-
private let externalURLSubject = PassthroughSubject<URL?, Never>()
62+
private let urlSubject = PassthroughSubject<OpenURLType, Never>()
5563
private let authenticatedSubject = PassthroughSubject<Bool, Never>()
5664
private var authRepository: AuthRepositoryProtocol?
5765
private var appConfigRepository: AppConfigRepositoryProtocol?
@@ -61,7 +69,7 @@ final class SettingViewModel: ViewModel {
6169
generalNotificationEnabled: generalNoticeEnabledSubject.eraseToAnyPublisher(),
6270
pushNotificationEnabled: pushNoticeEnabledSubject.eraseToAnyPublisher(),
6371
versionPublisher: versionSubject.eraseToAnyPublisher(),
64-
urlPublisher: externalURLSubject.eraseToAnyPublisher(),
72+
urlPublisher: urlSubject.eraseToAnyPublisher(),
6573
isAuthenticatedPublisher: authenticatedSubject.eraseToAnyPublisher())
6674
}
6775

@@ -73,8 +81,8 @@ final class SettingViewModel: ViewModel {
7381
togglePushNotification()
7482
case .update:
7583
updateBitnagil()
76-
case .openURL(type: let type):
77-
externalURLSubject.send(type.url)
84+
case .openURL(let type):
85+
handleURL(type: type)
7886
case .logout:
7987
logout()
8088
case .withdrawal:
@@ -102,7 +110,8 @@ final class SettingViewModel: ViewModel {
102110
}
103111

104112
private func updateBitnagil() {
105-
// TODO: - 앱스토어 열기
113+
guard let url = URLType.update.url else { return }
114+
urlSubject.send(.external(url: url))
106115
}
107116

108117
private func logout() {
@@ -144,4 +153,10 @@ final class SettingViewModel: ViewModel {
144153
}
145154
}
146155
}
156+
157+
private func handleURL(type: URLType) {
158+
guard let url = type.url else { return }
159+
160+
urlSubject.send(.internal(url: url))
161+
}
147162
}

SupportingFiles/Info.plist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
<key>LSApplicationQueriesSchemes</key>
3535
<array>
3636
<string>kakaokompassauth</string>
37+
<string>itms-apps</string>
3738
</array>
3839
<key>UIAppFonts</key>
3940
<array>

0 commit comments

Comments
 (0)