首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >从远程配置获取

从远程配置获取
EN

Stack Overflow用户
提问于 2017-02-21 18:12:16
回答 1查看 834关注 0票数 0

我试图从远程配置变量中检索一些数据,但是我一直从我的plist文件中获取值。这是我的密码:

代码语言:javascript
复制
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()
}

打印总是从my plist返回值。

EN

回答 1

Stack Overflow用户

发布于 2017-02-21 20:02:14

新手错误:我们在Firebase中有两个项目,我试图从错误的项目中获得值,对不起。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42374856

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档