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

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

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

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

问题是,两天后,Firebase控制台一直说0个用户参与了实验。 另一方面,我在Android上用相同的代码完成了另一个测试,我可以在几个小时后看到活动。

有什么我想念的吗?

编辑 – 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) 

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

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

嗯…我会说实话,看起来你在这里正在做的一切。

请注意,您设置远程配置获取的方式,将需要两个会话才能使更改生效(您基本上遵循此博客文章中描述的“下次加载值”方法),因此它可能会这两天是获取任何数据所需的最低限度,具体取决于人们使用您应用的频率。 也许再等一两天,看看发生了什么。

此外,显然,这是不言而喻的,但如果您刚刚发布了具有更新库和所有内容的应用程序的新版本,您可能还需要等待一段时间才能让所有用户更新到最新版本的应用程序,

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

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

因此,这是解决方法(使用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]; });