1

我正在使用 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

4

2 回答 2

3

我用这个模块安装了它,它工作得很好,你可以试试这个:

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

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

然后是配置远程配置,以便 ab 测试为您工作

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

于 2018-12-20T12:50:16.363 回答
3

我正在使用 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

于 2018-12-20T12:54:34.133 回答