远程配置 A/B 测试未在 iOS 上提供结果

Remote Config A/B Test does not provide results on iOS

2 天前,我使用以下代码在我的 iOS 应用程序上创建并启动了 Firebase 远程配置的 A/B 测试:

[FIRApp configure];
[FIRRemoteConfig.remoteConfig fetchWithCompletionHandler:^(FIRRemoteConfigFetchStatus status, NSError * _Nullable error) {
        // Do nothing
    }];
[FIRRemoteConfig.remoteConfig activateFetched];

我已确认测试正在进行,因为在某些设备上我可以看到正在进行的测试。

问题是,两天后,Firebase 控制台一直显示有 0 个用户参与了实验。另一方面,我用相同的代码对 Android 进行了另一项测试,几个小时后我可以看到 activity。

有什么我遗漏的吗?

编辑 - Pods 个版本:

Using Firebase (4.5.0)
Using FirebaseABTesting (1.0.0)
Using FirebaseAnalytics (4.0.4)
Using FirebaseCore (4.0.10)
Using FirebaseInstanceID (2.0.5)
Using FirebasePerformance (1.0.6)
Using FirebaseRemoteConfig (2.1.0)

嗯...老实说,看起来你在这里做的一切。

请注意,您设置远程配置获取的方式需要两次会话才能使更改生效(您基本上遵循 [=10= 中描述的 "Load values for next time" 方法]) 所以两天可能是获取任何数据所需的最低限度,具体取决于人们使用您的应用程序的频率。也许再等一两天,看看发生了什么。

另外,很明显,这是不言而喻的,但是如果您刚刚发布了包含更新的库和所有内容的新版本应用程序,您可能还需要稍等片刻,让所有用户都更新到您应用的最新版本,

最后我重现了这个问题并找到了解决方法。

关键是从 application:didFinishLaunchingWithOptions: 方法中分离 activateFetched

因此,这是解决方法(使用 Firebase 4.7.0 测试):

[FIRApp configure];
[FIRRemoteConfig.remoteConfig fetchWithExpirationDuration:60*60 completionHandler:^(FIRRemoteConfigFetchStatus status, NSError * _Nullable error) {
    // Do nothing
}];

dispatch_async(dispatch_get_main_queue(), ^{
    [FIRRemoteConfig.remoteConfig activateFetched];
});

问题是您在 fetch 方法之外调用了 activateFetched()。 您应该在完成处理程序 returns 成功时调用它:

[FIRRemoteConfig.remoteConfig fetchWithExpirationDuration:expirationDuration completionHandler:^(FIRRemoteConfigFetchStatus status, NSError *error) {
    if (status == FIRRemoteConfigFetchStatusSuccess) {
        [FIRRemoteConfig.remoteConfig activateFetched];
    } else {
        // Manage error case
    }
}];