-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Splash 화면에서 앱 버전 조회 및 업데이트 필요할 시 앱스토어로 보내는 기능 구현
- Loading branch information
Showing
7 changed files
with
118 additions
and
11 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
Projects/Core/Core/Sources/Network/APIs/VersionAPI/Repository/VersionAPI.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,38 @@ | ||
import Foundation | ||
|
||
enum VersionAPI { | ||
case version(VersionRequestDTO) // 버전조회 | ||
} | ||
|
||
extension VersionAPI: TargetType { | ||
var baseURL: URL? { | ||
return try? Config.base.asURL() | ||
} | ||
|
||
var path: String { | ||
switch self { | ||
case .version: | ||
return "v1/version" | ||
} | ||
} | ||
|
||
var method: HTTPMethod { | ||
switch self { | ||
case .version: | ||
return .post | ||
} | ||
} | ||
|
||
var task: HTTPTask { | ||
switch self { | ||
case let .version(param): | ||
return .requestJSONEncodable(params: param) | ||
} | ||
} | ||
|
||
var headers: [String : String]? { | ||
return [ | ||
"Content-Type": "application/json;charset=UTF-8" | ||
] | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
Projects/Core/Core/Sources/Network/APIs/VersionAPI/Repository/VersionRepository.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,20 @@ | ||
import Foundation | ||
|
||
public protocol VersionRepositoryInterface { | ||
func get() async throws | ||
} | ||
|
||
public final class VersionRepository: VersionRepositoryInterface { | ||
private let networkManager: NetworkManagerInterfacae | ||
|
||
public init(networkManager: NetworkManagerInterfacae) { | ||
self.networkManager = networkManager | ||
} | ||
|
||
public func get() async throws { | ||
if let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String { | ||
let targetType = VersionAPI.version(VersionRequestDTO(version: version)) | ||
try await networkManager.request(target: targetType) | ||
} | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
Projects/Core/Core/Sources/Network/APIs/VersionAPI/RequestDTO/VersionRequestDTO.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,5 @@ | ||
import Foundation | ||
|
||
struct VersionRequestDTO: Encodable { | ||
let version: String | ||
} |
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
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