无法包括针对React Native应用程序的AB测试

时间:2018-12-20 11:39:57

标签: react-native react-native-android react-native-ios firebase-ab-testing

我正在使用Firebase为我的React Native应用程序集成A / B测试。我尝试了两种方法-使用react-native-ab和react-native-ab-test。

在第一种情况下,我收到一条错误消息:“未定义不是对象(正在评估PropTypes.string)”

在第二种情况下,我收到一条错误消息:“ index.ios.js试图要求'react-native',但是提供了此模块的文件有多个。您可以删除或修复它们。”

在两种情况下,我都只是通过将依赖项导入到我的JS文件中而得到这些错误。通过查看两个依赖项的github页面,我认为不需要链接两个依赖项并且它们运行良好。

链接: https://github.com/lwansbrough/react-native-ab https://github.com/landaio/react-native-ab-test

2 个答案:

答案 0 :(得分:2)

我使用此模块安装了它,它运行完美,您可以尝试以下方法:

https://github.com/invertase/react-native-firebase

https://rnfirebase.io/docs/v5.x.x/getting-started

然后配置远程配置,以便您进行a-b测试

https://rnfirebase.io/docs/v5.x.x/config/reference/config

答案 1 :(得分:1)

我正在使用A / B测试,并通过以下模块为我工作:

"react-native-firebase": "3.3.1",

,并且也需要pod

pod 'Firebase/Core', '~> 5.11.0'
pod 'Firebase/RemoteConfig', '~> 5.11.0'

我的逻辑

import firebase from 'react-native-firebase';

setRemoteConfigDefaults() {
    if (__DEV__) {
      firebase.config().enableDeveloperMode();
    }

    // Set default values
    firebase.config().setDefaults({
      my_variant_remote_config_param: ''
    });
  }

/**
 * FIREBASE remote config fetch
 * @param valueToFetch: remote config key
 */
export const fetchRemoteConfig = async (valueToFetch: RemoteConfigKeysTypes): Promise<string> => {
  try {
    await firebase.config().fetch();
    await firebase.config().activateFetched();
    const snapshot = await firebase.config().getValue(valueToFetch);

    const response = snapshot.val();

    return response;
  } catch (error) {
    firebase.analytics().logEvent('remote_config_get_value_error', { error, key: valueToFetch });
    return null;
  }
};

更多信息: https://www.npmjs.com/package/react-native-firebase