无法包括针对React Native应用程序的AB测试 [英] Unable to include AB Testing for React Native application
问题描述
我正在使用Firebase为我的React Native应用程序集成A/B测试.我尝试了两种方法-使用react-native-ab和react-native-ab-test.
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.
在第一种情况下,我收到一条错误消息,提示未定义不是对象(正在评估PropTypes.string)"
In the first case, I get an error saying "undefined is not an object(evaluating PropTypes.string)"
在第二种情况下,我收到一条错误消息:"index.ios.js试图要求'react-native',但是提供了此模块的文件有多个.您可以删除或修复它们."
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."
在两种情况下,我都只是通过将依赖项导入到我的JS文件中而得到这些错误.通过查看两个依赖项的github页面,我认为不需要链接两个依赖项,并且它们运行良好.
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.
链接: https://github.com/lwansbrough/react-native-ab https://github.com/landaio/react-native-ab-test
推荐答案
我正在使用A/B测试,并通过以下模块为我工作:
I'm using A/B testing and works for me with this module:
"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
这篇关于无法包括针对React Native应用程序的AB测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!