2017-02-21 2 views
0

원격 설정 변수에서 일부 데이터를 가져 오려고하는데 내 plier 파일에서 값을 계속 가져오고 있습니다.원격 설정에서 가져 오기

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"블록 내에서 print 문을 사용합니까? –

+0

내 plist 파일에서 동일한 값을 반환합니다. – GusDev

답변

0

신기한 실수 : Firebase에 두 개의 프로젝트가 있으며 잘못된 프로젝트에서 값을 가져 오려고했습니다. 죄송합니다.