【问题标题】:get from Remote config从远程配置获取
【发布时间】: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


【解决方案1】:

新手错误:我们在 Firebase 中有两个项目,我试图从错误的项目中获取值,抱歉。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-19
    • 1970-01-01
    • 1970-01-01
    • 2017-11-08
    相关资源
    最近更新 更多