-
Notifications
You must be signed in to change notification settings - Fork 3
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/#311 앱스토어의 앱 버전과 기존 앱의 버전을 추적하여 강제 업데이트 기능 #313
base: dev
Are you sure you want to change the base?
Changes from 6 commits
abc58dd
976c89e
a215197
f5dd3c8
5cefc75
b8e4353
f1f9aad
edffe09
f0ba96c
3637db5
b407074
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// | ||
// AppStoreCheck.swift | ||
// App | ||
// | ||
// Created by Jisoo Ham on 5/26/24. | ||
// Copyright © 2024 Pepsi-Club. All rights reserved. | ||
// | ||
|
||
import UIKit | ||
|
||
import Core | ||
|
||
public final class AppStoreCheck { | ||
|
||
/// 프로젝트 버전 | ||
let appVersion = String.getCurrentVersion() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용되지 않는 변수인데 남겨두신 이유가 있으신가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sceneDelegate에서 가져다 쓰려고 뒀는데 scene에서도 또 변수 만들어서 썼네요 🥲 수정하겠습니다 ~ |
||
|
||
/// 앱스토어에 등록된 앱의 ID | ||
static let appleID = Bundle.main.object(forInfoDictionaryKey: "APPLE_ID") as? String | ||
|
||
/// 앱스토어 연결 링크 | ||
static let appStoreURLString | ||
= "itms-apps://itunes.apple.com/app/apple-store/" | ||
|
||
/// 앱스토어에 등록된 최신 버전 가져오는 함수 | ||
|
||
static public func latestVersion() async -> String? { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수 시그니처를 () -> Observable으로 변경하는 게 어떨까요? |
||
guard let appleID = AppStoreCheck.appleID, | ||
let url | ||
= URL(string: "https://itunes.apple.com/lookup?id=\(appleID)&country=kr") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 린트 오류 수정바랍니다! |
||
else { return nil } | ||
|
||
do { | ||
let (data, _) = try await URLSession.shared.data( | ||
for: URLRequest(url: url) | ||
) | ||
|
||
guard let json = try? JSONSerialization.jsonObject( | ||
with: data, | ||
options: .allowFragments | ||
) as? [String: Any], | ||
let results = json["results"] as? [[String: Any]], | ||
let appStoreVersion = results[0]["version"] as? String | ||
else { | ||
return nil | ||
} | ||
|
||
return appStoreVersion | ||
} catch { | ||
return nil | ||
} | ||
} | ||
|
||
/// URL을 통해 앱스토어 오픈 | ||
static public func openAppStore() { | ||
guard let appleID, | ||
let url = URL(string: AppStoreCheck.appStoreURLString + appleID) | ||
else { return } | ||
|
||
if UIApplication.shared.canOpenURL(url) { | ||
UIApplication.shared.open(url) | ||
} | ||
} | ||
} |
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.
APPLE_ID가 유저의 apple 계정 id로 유추되어서 APPSTORE_ID와 같이 표현하면 어떨까요?
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.
변경하겠습니다 !