2017-02-21 61 views
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返回值。

+0

如果你把「取值!」在「if status == .success」塊中打印語句? –

+0

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

回答

0

新手錯誤:我們在Firebase中有兩個項目,我試圖從錯誤的項目中獲取值,對不起。