Unable to include AB Testing for React Native application

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-16 13:58:50

问题


I am integrating A/B Testing for my React Native application using Firebase. I have tried two methods - using react-native-ab and react-native-ab-test.

In the first case, I get an error saying "undefined is not an object(evaluating PropTypes.string)"

In the second case, I get an error saying "index.ios.js tries to require 'react-native' but there are several files providing this module. You can delete or fix them."

In both the cases, I get these errors just by importing the dependency in my JS file. By seeing the github pages of both dependencies, I think there is no need to link both the dependencies and they run fine.

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


回答1:


I installed it with this module and it works perfectly, you can try this:

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

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

and then it is to configure the remote config so that the a-b test works for you

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




回答2:


I'm using A/B testing and works for me with this module:

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

and needs pod too.

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

My logic

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;
  }
};

More Info: https://www.npmjs.com/package/react-native-firebase



来源:https://stackoverflow.com/questions/53867960/unable-to-include-ab-testing-for-react-native-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!