【发布时间】:2017-07-11 12:29:33
【问题描述】:
我正在尝试从我的远程配置变量中检索一些数据,但我一直从我的 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()
}
print 总是从我的 plist 返回值。
【问题讨论】:
-
如果你把“取值!” “if status == .success”块内的打印语句?
-
从我的 plist 文件中返回相同的值
标签: ios firebase firebase-remote-config