0
我試圖從我的遠程配置變量檢索一些數據,但我不斷從我的plist文件中獲取值。這是我的代碼:從遠程配置
let apolloConfigKey = "dev_username"
var remoteConfig: FIRRemoteConfig!
func createDefaults(){
remoteConfig = FIRRemoteConfig.remoteConfig()
let remoteConfigSettings = FIRRemoteConfigSettings(developerModeEnabled: true)
remoteConfig.configSettings = remoteConfigSettings!
remoteConfig.setDefaultsFromPlistFileName("RemoteConfigDefaults")
fetchConfig()
}
func fetchConfig(){
print("Value fetched! \(remoteConfig[apolloConfigKey].stringValue)")
var expirationDuration = 3600
if remoteConfig.configSettings.isDeveloperModeEnabled {
expirationDuration = 0
}
remoteConfig.fetch(withExpirationDuration: TimeInterval(expirationDuration)) { (status, error) -> Void in
if status == .success {
print("Config fetched!")
self.remoteConfig.activateFetched()
} else {
print("Config not fetched")
print("Error \(error!.localizedDescription)")
}
//self.displayWelcome()
}
}
func getRemoteValue(){
createDefaults()
}
的打印總是從我的的plist返回值。
如果你把「取值!」在「if status == .success」塊中打印語句? –
從我的plist文件返回相同的值 – GusDev