2016-11-24 2 views
1

Firebase의 RemoteConfig 프레임 워크를 사용하고 있습니다. Firebase 서버에서 데이터를 가져 오는 것이 좋습니다 (이미 프로덕션 환경에서 작동 중). 기본값 설정은 작동하지 않습니다. 나는 문서에 충실하려고했지만 어쩌면 내가 뭔가 잘못하고있는 것 같아. Firebase가 RemoteConfig 기본값을 설정할 수 없습니다

은 내가 다음 않았다이를 테스트하려면 :

[self.remoteConfig setDefaults:@{@"key1": @"value1"}]; 

는 다음, Firebase Console에서 나는 클라이언트에 제로 데이터를 전송 기본 No Value을 가지고 매개 변수 key1을 설정합니다. 나는 다른 조건을 정의하지 않았으므로 이것이 보낼 유일한 가치입니다. documentation에 따르면 RemoteConfig 개체는이 경우 기본값을 선택해야합니다.

가져 오기 코드 :

[self.remoteConfig fetchWithExpirationDuration:self.configurationExpirationDuration 
          completionHandler:^(FIRRemoteConfigFetchStatus status, 
               NSError * _Nullable error) { 
    if (status == FIRRemoteConfigFetchStatusSuccess) { 
    [self.remoteConfig activateFetched]; 

    FIRRemoteConfigValue *remoteValue1 = [self.remoteConfig configValueForKey:@"key1"]; 
    NSString *value1 = remoteValue1.stringValue; 

    // Logic comes here 

    } else { 
    LogError(@"Error fetching remote configuration from Firebase: %@", error); 
} 

remoteValue1nil 없습니다.

value1nil입니다.

remoteValue1.dataValue_NSZeroData입니다. 또한

, 나는 (과 namespace 매개 변수에 nil을 보내는 것은 나에게 기본 네임 스페이스 기본값을 줄 것이다 가정)을 nil 가치를 얻을

[self.remoteConfig defaultValueForKey:@"key1" namespace:nil] 

를 사용하려고합니다.

여기 뭔가 잘못 되었나요?

답변

1

configValueForKey : 메소드는 먼저 Firebase 서버에서 결과를 가져 오는 지 검사하고, 결과가 존재하면 기본값 대신 원격 결과를 반환합니다.

그래서 key1 값은 콘솔에 설정 한 값이어야합니다.이 값은 nil (값 없음)입니다.

defaultVaueForKey를 호출 할 때 : namespace : 항상 기본 네임 스페이스 FIRNamespaceGoogleMobilePlatform을 사용해야합니다. nil을 사용하면 유효한 구성 결과가 반환되지 않습니다.

+0

감사합니다. 어떻게 든 헤더 파일의'FIRNamespaceGoogleMobilePlatform' const가 누락되었습니다. –