我正在使用Firebase的RemoteConfig
框架。 从Firebase服务器提取数据可以正常工作(已在生产环境中工作),但设置默认值似乎不起作用。我试图坚持文档,但也许我做错了什么。Firebase无法设置RemoteConfig的默认设置
为了验证这一点,我做了以下内容:
[self.remoteConfig setDefaults:@{@"key1": @"value1"}];
然后,在Firebase Console
我设置参数key1
有发送零数据到客户端的默认No Value
。我没有定义任何其他条件,所以这是将被发送的唯一值。根据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);
}
remoteValue1
不nil
。
value1
是nil
。
remoteValue1.dataValue
是_NSZeroData
。
而且,当我尝试使用
[self.remoteConfig defaultValueForKey:@"key1" namespace:nil]
我得到一个nil
值(假设发送nil
到作为namespace
参数会给我默认命名空间的默认值)。
我在这里做错了什么?
谢谢,我不知何故错过了头文件中的FIRNamespaceGoogleMobilePlatform常量。 –