Last active
April 22, 2022 13:27
-
-
Save lhas-dev/444b6cfff7ff3400fb1aabe217d47732 to your computer and use it in GitHub Desktop.
How to use Remote Config in Firebase for A/B Testing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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