[英]Firebase Remote Config unable to fetch values from console
I am using react-native-firebase https://rnfirebase.io/remote-config/usage to try fetching my values.我正在使用 react-native- firebase https://rnfirebase.io/remote-config/usage来尝试获取我的值。
Firebase says it has fetched my values because I am receiving this console log: Firebase 说它已经获取了我的值,因为我收到了这个控制台日志:
"Configs were retrieved from the backend and activated."
BUT - when I try to output just the value I can only see the default values if they are set.但是 - 当我尝试 output 时,我只能看到设置的默认值。
I am aware of the way firebase is caching remote config, but I still cant get it to work by setting a custom cache timeout.我知道 firebase 缓存远程配置的方式,但我仍然无法通过设置自定义缓存超时来使其工作。
I'm not so sure what I could be doing wrong.我不太确定我做错了什么。
Here is my code which executes on app load.这是我在应用加载时执行的代码。
async componentDidMount() {
await remoteConfig()
.setConfigSettings({
minimumFetchInterval: 10,
minimumFetchIntervalMillis: 10000, // 10 secs
fetchTimeMillis: 10000
})
await remoteConfig()
.setDefaults({
min_app_version: 1.17,
test_param: 'disabled'
})
// await remoteConfig().fetch(0);
await remoteConfig().fetchAndActivate(0)
.then(fetchedRemotely => {
if (fetchedRemotely) {
console.log(
'+++Configs were retrieved from the backend and activated.',
);
console.log(fetchedRemotely);
} else {
console.log(
'+++++No configs were fetched from the backend, and the local configs were already activated',
);
}
});
//Code to get All parameters from Firebase Remote config
//ONLY default values show here if they are set
const parameters = remoteConfig().getAll();
Object.entries(parameters).forEach($ => {
const [key, entry] = $;
console.log('--Key: ', key);
console.log('--Source: ', entry.getSource());
console.log('--Value: ', entry.asString());
console.log('--------------------------------');
});
const minAppVersion = remoteConfig().getValue('min_app_version');
const isApplicationOn = remoteConfig().getBoolean('is_application_on');
//set value in redux (local storage)
this.props.minAppVersionFirebaseRemoteConfig(minAppVersion._value)
console.log(minAppVersion)
console.log(isApplicationOn)
}
The issue was my google plist file from firebase was not copying over properly in my xCode build phase script so things were not entirely in sync.问题是我来自 firebase 的 google plist 文件在我的 xCode 构建阶段脚本中没有正确复制,所以事情并不完全同步。
For example, I used this to copy the right file over.例如,我用它来复制正确的文件。 I was using an if/else condition before that was not working, so I changed to a switch sdtatement and its fine now.
在此之前我使用的是 if/else 条件,所以我改为使用 switch sdstatement,现在它很好。
I fixed this by using case/switch instead of if/else...我通过使用 case/switch 而不是 if/else 来解决这个问题...
case "${CONFIGURATION}" in
"Release" )
echo "BUILD CONFIG: RELEASE"
cp -r "${RELEASE_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
"dev.release" )
echo "BUILD CONFIG: RELEASE DEV"
cp -r "${RELEASE_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
"Debug" )
echo "BUILD CONFIG: DEBUG"
cp -r "${DEBUG_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
"dev.debug" )
echo "BUILD CONFIG: DEBUG DEV"
cp -r "${DEBUG_INFO_PLIST_FILE}" "${PLIST_DESTINATION}" ;;
*)
I really don't know why the if/else was not working, but, I hope this helps someone!我真的不知道为什么 if/else 不起作用,但是,我希望这对某人有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.