generated from dannaward/create-ios-app
-
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.
[Feat] #176 - 강제 업데이트 로직 추가
- Loading branch information
Showing
14 changed files
with
297 additions
and
50 deletions.
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
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,51 @@ | ||
// | ||
// FirebaseService.swift | ||
// pophory-iOS | ||
// | ||
// Created by 강윤서 on 7/22/24. | ||
// | ||
|
||
import Firebase | ||
import FirebaseRemoteConfig | ||
|
||
final class FirebaseService { | ||
static let shared = FirebaseService() | ||
|
||
private let config = RemoteConfig.remoteConfig() | ||
|
||
enum RemoteConfigType: String { | ||
case minimumVersion = "minimum_update_version_iOS" | ||
} | ||
|
||
private init() { | ||
self.setRemoteConfigSetting() | ||
} | ||
} | ||
|
||
extension FirebaseService { | ||
private func setRemoteConfigSetting() { | ||
let setting = RemoteConfigSettings() | ||
setting.minimumFetchInterval = 0 | ||
setting.fetchTimeout = 1 | ||
config.configSettings = setting | ||
} | ||
|
||
func fetchRemoteConfig(type: RemoteConfigType) async -> String? { | ||
return await withCheckedContinuation { continuation in | ||
config.fetch { status, error in | ||
if status == .success { | ||
self.config.activate { change, error in | ||
guard let version = self.config[type.rawValue].stringValue, | ||
!version.isEmpty else { | ||
continuation.resume(returning: nil) | ||
return | ||
} | ||
continuation.resume(returning: version) | ||
} | ||
} else { | ||
continuation.resume(returning: nil) | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.