Followed the below example using Remote Config. But I am getting error.
if (__DEV__) {
firebase.config().enableDeveloperMode();
}
// Set default values
firebase.config().setDefaults({
hasExperimentalFeature: false,
});
firebase.config().fetch()
.then(() => {
return firebase.config().activateFetched();
})
.then((activated) => {
if (!activated) console.log('Fetched data not activated');
return firebase.config().getValue('hasExperimentalFeature');
})
.then((snapshot) => {
const hasExperimentalFeature = snapshot.val();
if(hasExperimentalFeature) {
// call some function
}
// continue booting app
})
.catch(console.error);
It returns an error : Error: fetch() operation cannot be completed successfully
React Native
version: 0.56.0React Native Firebase
Version: react-native-firebase@4.3.8Firebase
Module: Remote Configtypescript
? noMy solution was to put the fetch function inside a Promise. Ex:
try {
return new Promise(
(resolve) => {
resolve(
firebase.config()
fetch()
.then(() => {
return firebase.config().activateFetched();
})
.then((activated) => {
if (!activated) console.log('Fetched data not activated');
return firebase.config().getValue('hasExperimentalFeature');
})
.then((snapshot) => {
const hasExperimentalFeature = snapshot.val();
if (hasExperimentalFeature) {
// call some function
}
// continue booting app
})
.catch(console.error)
)
);
} catch (err) {
console.warn(err)
}