-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[feat] 환경설정 앱 버전 정보 셀 로직 추가, 강제 업데이트 기능 추가 #201 #203 #206
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// | ||
// OptionalBool.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/13. | ||
// | ||
|
||
import Foundation | ||
|
||
/// 옵셔널 불 | ||
enum OptionalBool { | ||
|
||
/// 참 | ||
case `true` | ||
|
||
/// 거짓 | ||
case `false` | ||
|
||
/// 닐 | ||
case `nil` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
Happiggy-bank/Happiggy-bank/Extensions/UIViewController+VersionUpdating.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// | ||
// UIViewController+VersionUpdating.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/22. | ||
// | ||
|
||
import UIKit | ||
|
||
extension UIViewController: VersionUpdating { | ||
|
||
// MARK: - Enums | ||
|
||
private enum StringLiteral { | ||
/// 알림 제목 | ||
static let appStoreOpenErrorAlertTitle = "앱스토어를 열 수 없습니다." | ||
static let appStoreOpenErrorAlertMessage = "앱스토어에서 행복저금통을 직접 업데이트 해 주세요." | ||
} | ||
|
||
|
||
// MARK: - Properties | ||
|
||
/// 강제 업데이트 알림 | ||
private var forceUpdateAlert: UIAlertController { | ||
let confirmAction = UIAlertAction.confirmAction(title: "업데이트") { _ in | ||
VersionManager.shared.forceUpdateAlertIsPresented.toggle() | ||
self.openAppStore() | ||
} | ||
|
||
return UIAlertController.basic( | ||
alertTitle: "필수 업데이트가 있습니다", | ||
confirmAction: confirmAction | ||
) | ||
} | ||
|
||
/// 강제 업데이트 오류 시 앱 종료를 확인하는 알림 | ||
private var closeAppAlert: UIAlertController { | ||
let confirmAction = UIAlertAction.confirmAction(title: "앱 종료", style: .default) { _ in | ||
exit(.zero) | ||
} | ||
|
||
return UIAlertController.basic( | ||
alertTitle: StringLiteral.appStoreOpenErrorAlertTitle, | ||
alertMessage: StringLiteral.appStoreOpenErrorAlertMessage, | ||
confirmAction: confirmAction | ||
) | ||
} | ||
|
||
/// 앱스토어를 열 수 없을 때 나타나는 알림 | ||
private var selfUpdateAlert: UIAlertController { | ||
UIAlertController.basic( | ||
alertTitle: StringLiteral.appStoreOpenErrorAlertTitle, | ||
alertMessage: StringLiteral.appStoreOpenErrorAlertMessage, | ||
confirmAction: UIAlertAction.confirmAction() | ||
) | ||
} | ||
|
||
|
||
// MARK: - Functions | ||
|
||
/// 앱스토어를 여는 메서드 | ||
func openAppStore() { | ||
guard let urlString = VersionManager.shared.appStoreVersionInfo?.trackViewUrl, | ||
let url = URL(string: urlString), | ||
UIApplication.shared.canOpenURL(url) | ||
else { | ||
let alertController = (VersionManager.shared.needsForcedUpdate) ? | ||
self.closeAppAlert : self.selfUpdateAlert | ||
return self.present(alertController, animated: true) | ||
} | ||
|
||
url.open() | ||
} | ||
|
||
/// 강제 업데이트가 필요하고, 아직 알림이 띄워지지 않은 경우 알림을 띄우는 메서드 | ||
func presentForceUpdateAlertIfNeeded() { | ||
guard !VersionManager.shared.forceUpdateAlertIsPresented | ||
else { return } | ||
|
||
VersionManager.shared.forceUpdateAlertIsPresented.toggle() | ||
self.present(self.forceUpdateAlert, animated: true) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// URL+AppStore.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/20. | ||
// | ||
|
||
import Foundation | ||
|
||
extension URL { | ||
|
||
/// 앱스토어 URL | ||
enum AppStore { | ||
/// 앱스토어 앱 정보 url | ||
static let appInfo = URL(string: StringLiteral.appInfo) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// URL+Open.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/22. | ||
// | ||
|
||
import UIKit | ||
|
||
extension URL { | ||
|
||
/// url을 엶 | ||
func open(completionHandler: ((Bool) -> Void)? = nil) { | ||
UIApplication.shared.open(self, options: [:], completionHandler: completionHandler) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// | ||
// LookUpResult.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/20. | ||
// | ||
|
||
import Foundation | ||
|
||
/// 앱스토어에서 가져온 앱 정보 | ||
struct AppStoreVersionInfo: Decodable { | ||
/// 배포중인 버전 | ||
var version: String | ||
|
||
/// 앱 릴리즈 노트 | ||
var releaseNotes: String | ||
|
||
/// 다운로드 url | ||
var trackViewUrl: String | ||
} | ||
|
||
|
||
/// 앱스토어에서 가져온 앱 정보 배열 | ||
struct LookUpResult: Decodable { | ||
/// 결과 배열 | ||
var results: [AppStoreVersionInfo] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Happiggy-bank/Happiggy-bank/Protocol/VersionChecking.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// VersionChecking.swift | ||
// Happiggy-bank | ||
// | ||
// Created by sun on 2022/05/13. | ||
// | ||
|
||
import Foundation | ||
|
||
/// 앱 설치된 버전, 앱스토어 최신 버전 확인 기능 | ||
protocol VersionChecking { | ||
|
||
// MARK: - Properties | ||
|
||
/// 업데이트 필요 여부 | ||
var needsUpdate: OptionalBool { get } | ||
|
||
/// 강제 업데이트 필요 여부 | ||
var needsForcedUpdate: Bool { get } | ||
|
||
/// 설치된 버전 | ||
var installedVersion: String? { get } | ||
|
||
/// 최신 버전 | ||
var latestVersion: String? { get } | ||
|
||
/// 앱스토어 앱 버전 확인 후 필요한 작업을 수행 | ||
func checkVersionOnAppStore(completionHandler: ((Bool) -> Void)?) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
업데이트 필요 여부인데 optionalBool로 한 이유가 따로 있을까요? (아래에서 더 이어짐)