【发布时间】:2018-08-31 20:54:19
【问题描述】:
我正在使用 Firebase 的 RemoteConfig 框架。
从 Firebase 服务器获取数据工作正常(已经在生产中工作),但设置默认值似乎不起作用。我试图坚持文档,但也许我做错了什么。
为了测试这一点,我做了以下操作:
[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 参数发送给我默认的命名空间默认值)。
我在这里做错了吗?
【问题讨论】:
标签: ios firebase firebase-remote-config