Skip to content

Instantly share code, notes, and snippets.

@lhas-dev
Last active April 22, 2022 13:27
Show Gist options
  • Save lhas-dev/444b6cfff7ff3400fb1aabe217d47732 to your computer and use it in GitHub Desktop.
Save lhas-dev/444b6cfff7ff3400fb1aabe217d47732 to your computer and use it in GitHub Desktop.
How to use Remote Config in Firebase for A/B Testing
import remoteConfig from '@react-native-firebase/remote-config'
const fetchConfig = async () => {
await remoteConfig().setConfigSettings({
isDeveloperModeEnabled: __DEV__,
minimumFetchInterval: 0
})
await remoteConfig().fetchAndActivate()
}
const getRemoteValue = key => remoteConfig().getValue(key).value
// In your React component (or any other):
import { useEffect } from 'react';
useEffect(() => {
const callback = async () => {
await fetchConfig();
const sampleRemoteConfig = getRemoteValue('sampleRemoteConfig');
console.log(sampleRemoteConfig);
};
callback();
}, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment