![](/img/trans.png)
[英]Firebase Remote Config: Can't read any values, but fetch is successful
[英]Firebase Remote Config unable to fetch values from console
我正在使用 react-native- firebase https://rnfirebase.io/remote-config/usage來嘗試獲取我的值。
Firebase 說它已經獲取了我的值,因為我收到了這個控制台日志:
"Configs were retrieved from the backend and activated."
但是 - 當我嘗試 output 時,我只能看到設置的默認值。
我知道 firebase 緩存遠程配置的方式,但我仍然無法通過設置自定義緩存超時來使其工作。
我不太確定我做錯了什么。
這是我在應用加載時執行的代碼。
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)
}
問題是我來自 firebase 的 google plist 文件在我的 xCode 構建階段腳本中沒有正確復制,所以事情並不完全同步。
例如,我用它來復制正確的文件。 在此之前我使用的是 if/else 條件,所以我改為使用 switch sdstatement,現在它很好。
我通過使用 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}" ;;
*)
我真的不知道為什么 if/else 不起作用,但是,我希望這對某人有所幫助!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.