Skip to content
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

[Bug] 앱 버전 업데이트 알람 로직 수정 #280

Merged
merged 1 commit into from
Feb 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 29 additions & 19 deletions Uni/Source/Scene/Splash/ViewController/SplashViewController.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Foundation
import UIKit

class SplashViewController: BaseViewController {
final class SplashViewController: BaseViewController {
// MARK: - Property
private let keyChains = HeaderUtils()
// MARK: - UI Property
Expand All @@ -12,7 +12,7 @@ class SplashViewController: BaseViewController {
override func viewDidLoad() {
super.viewDidLoad()
setLayout()
self.view.backgroundColor = .gray000
setConfig()
checkAndUpdateIfNeeded()
}
// MARK: - Setting
Expand All @@ -27,6 +27,7 @@ class SplashViewController: BaseViewController {
}
override func setConfig() {
super.setConfig()
self.view.backgroundColor = .gray000
}
// MARK: - Custom Method
private func setRootViewController() {
Expand Down Expand Up @@ -95,21 +96,23 @@ extension SplashViewController {
}
print(splitCurrentProjectVersionArray, "프로젝트 버전")
print(splitMarketingVersionArray, "실제 앱스토어 버전")

if splitCurrentProjectVersionArray.count > 0 && splitMarketingVersionArray.count > 0 {
if splitCurrentProjectVersion[0] < splitMarketingVersionArray[0] {
self.showMajorUpdateAlert()
} else if splitCurrentProjectVersionArray[1] < splitMarketingVersionArray[1] {
self.showMajorUpdateAlert()
} else if splitCurrentProjectVersionArray[2] < splitMarketingVersionArray[2] {
self.checkAppVersion(nowAppVersion: splitMarketingVersionArray)
} else {
print("현재 최신 버전입니다.")
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self.setRootViewController()
})
}
}
self.compareProjectVersion(projectVersion: splitCurrentProjectVersionArray, marketingVersion: splitMarketingVersionArray)
}
}
}
func compareProjectVersion(projectVersion: [Int], marketingVersion: [Int]) {
if projectVersion.count > 0 && marketingVersion.count > 0 {
if projectVersion[0] < marketingVersion[0] {
self.showMajorUpdateAlert()
} else if projectVersion[1] < marketingVersion[1] {
self.showMajorUpdateAlert()
} else if projectVersion[2] < marketingVersion[2] {
self.checkAppVersion(nowAppVersion: marketingVersion)
} else {
print("현재 최신 버전입니다.")
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self.setRootViewController()
})
}
}
}
Expand All @@ -121,20 +124,27 @@ extension SplashViewController {
if appVersion != nowAppVersion {
showMinorUpdateAlert()
userDefaultsManager.save(value: nowAppVersion, forkey: .appVersion)
} else {
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self.setRootViewController()
})
}
} else {
userDefaultsManager.save(value: nowAppVersion, forkey: .appVersion)
DispatchQueue.main.asyncAfter(deadline: .now() + 2, execute: {
self.setRootViewController()
})
}
}
func showMajorUpdateAlert() {
let alert = view.showAlert(title: "업데이트 알림", message: "더 나은 서비스로 찾아왔어요!", cancelButtonMessage: "", okButtonMessage: "업데이트", type: .noti)
alert.okButtonTapCompletion = { [weak self] in
alert.okButtonTapCompletion = {
AppStoreCheck().openAppStore()
}
}
func showMinorUpdateAlert() {
let alert = view.showAlert(title: "업데이트 알림", message: "더 나은 서비스로 찾아왔어요!", cancelButtonMessage: "취소", okButtonMessage: "업데이트", type: .alert)
alert.okButtonTapCompletion = { [weak self] in
alert.okButtonTapCompletion = {
AppStoreCheck().openAppStore()
}
alert.cancelButtonTapCompletion = { [weak self] in
Expand Down