远程配置A / B测试不会在测试设备上触发(或100%匹配)

问题描述 投票:1回答:1

所以我现在已经设置了几次A / B测试实验,无论它是处于“草稿”阶段(我使用InstanceID.instanceID().token()定位我的测试设备)还是完全启动并运行实验(我设置的地方)对于100%匹配我的应用程序包ID的用户而言,当我这样做时,我没有看到我的测试变体中的参数到达Remote Config:

func loadRemoteConfig()
{
    let remoteConfig = RemoteConfig.remoteConfig()
    let remoteConfigSettings = RemoteConfigSettings(developerModeEnabled: true)
    remoteConfig.configSettings = remoteConfigSettings!

    remoteConfig.setDefaults(fromPlist: "RemoteConfigDefaults")

    remoteConfig.fetch(withExpirationDuration: TimeInterval(1)) { (status, error) in

        if let actualError = error
        {
            DDLogError("error from loadRemoteConfig is \(actualError.localizedDescription)")
        } else {
            switch(status)
            {
            case RemoteConfigFetchStatus.noFetchYet, RemoteConfigFetchStatus.failure, RemoteConfigFetchStatus.throttled :
                DDLogDebug("loadRemoteConfig got a \(status) status")
            case RemoteConfigFetchStatus.success :
                break
            }

            remoteConfig.activateFetched()

            // my A/B test parameter doesn't arrive in this array, ever.
            let arrayOfKeys = remoteConfig.allKeys(from: RemoteConfigSource.remote, namespace: NamespaceGoogleMobilePlatform)
            print("array of keys is \(arrayOfKeys.count) & \(arrayOfKeys)")

            // do some stuff here, depending on what Firebase tells us to do...
        }
    }

    self.remoteConfig = remoteConfig
}

此代码位于初始视图控制器中,而不是应用程序委托中。

这是我的Firebase A / B页面的样子,我只想在其中显示演示的工具提示:

Firebase Experiment Page

如何使用RemoteConfig fetch显示A / B测试和实验参数?

ios firebase ab-testing firebase-remote-config
1个回答
1
投票

好的!这是我自己解决的问题之一。

发生的事情的关键在于我的问题的这句话:

此代码位于初始视图控制器中,而不是应用程序委托中。

发生的事情是applicationDidFinishLaunching:未必完成(或者更具体地说,remoteConfig.fetch的结果或完成块在applicationDidFinishLaunching结束之前没有被解雇)。

所以我在remoteConfig从Firebase检索到更新之前检查了初始视图控制器的viewDidLoad函数中的远程配置值。

remoteConfig.fetch的结果向新注册的观察者发送通知允许我出现我的A / B测试参数。

© www.soinside.com 2019 - 2024. All rights reserved.