从远程配置

问题描述:

我试图从我的远程配置变量检索一些数据,但我不断从我的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返回值。

+0

如果你把“取值!”在“if status == .success”块中打印语句? –

+0

从我的plist文件返回相同的值 – GusDev

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