1

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

2 Answers2

3

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

Brayan Salazar
  • 234
  • 3
  • 12
  • Thank you for your response, but what I would like to achieve is showing two different UI based on the type of variant. How can I display them in render() method? – Gautham Raj Ayyapparaj Dec 21 '18 at 05:40
  • first you must configure the `remote config` to obtain the variables from firebase https://firebase.google.com/docs/remote-config/ then in the firebase console you create the a/b tests so that these variables arrive differently and in your render you must already condition what you want to do with each variable. you must first make sure that the values arrive from the `remote config` and then follow this guide https://firebase.google.com/docs/ab-testing/abtest-config – Brayan Salazar Dec 21 '18 at 12:58
3

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

jose920405
  • 7,982
  • 6
  • 45
  • 71
  • Thank you for your response, but what I would like to achieve is showing two different UI based on the type of variant. How can I display them in render() method? – Gautham Raj Ayyapparaj Dec 21 '18 at 05:39