-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
63 additions
and
1 deletion.
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
46 changes: 46 additions & 0 deletions
46
Soomsil-USaint/Data/Client/Firebase/RemoteConfigClient.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,46 @@ | ||
// | ||
// RemoteConfigClient.swift | ||
// Soomsil-USaint | ||
// | ||
// Created by 정지혁 on 2/18/25. | ||
// | ||
|
||
import Foundation | ||
|
||
import ComposableArchitecture | ||
import FirebaseRemoteConfig | ||
|
||
@DependencyClient | ||
struct RemoteConfigClient { | ||
private static let minimumVersionkey: String = "min_version_ios" | ||
|
||
var getMinimumVersion: @Sendable () async throws -> String | ||
} | ||
|
||
extension DependencyValues { | ||
var remoteConfigClient: RemoteConfigClient { | ||
get { self[RemoteConfigClient.self] } | ||
set { self[RemoteConfigClient.self] = newValue } | ||
} | ||
} | ||
|
||
extension RemoteConfigClient: DependencyKey { | ||
static let liveValue: RemoteConfigClient = Self( | ||
getMinimumVersion: { | ||
let remoteConfig = RemoteConfig.remoteConfig() | ||
try await remoteConfig.fetchAndActivate() | ||
|
||
let minimumVersion = remoteConfig[minimumVersionkey].stringValue | ||
debugPrint(minimumVersion) | ||
return minimumVersion | ||
} | ||
) | ||
|
||
static let previewValue: RemoteConfigClient = Self( | ||
getMinimumVersion: { | ||
return "1.0.0" | ||
} | ||
) | ||
|
||
static let testValue: RemoteConfigClient = previewValue | ||
} |