Integrating CodePush Advanced: 1
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 React, {Component} from 'react'; | |
import App from './App'; | |
import codePush from 'react-native-code-push'; | |
import AsyncStorage from '@react-native-community/async-storage'; | |
import { | |
CODEPUSH_STAGING_DEPLOYMENT_KEY, | |
CODEPUSH_PRODUCTION_DEPLOYMENT_KEY, | |
} from './utils/constants'; | |
const codePushOptions = {checkFrequency: codePush.CheckFrequency.MANUAL}; | |
class AppWrappedInCodePush extends Component { | |
componentDidMount() { | |
AsyncStorage.getItem('IS_BETA_USER').then((isBetaUser) => { | |
if (isBetaUser && isBetaUser === 'true') { | |
console.log('Syncing with staging'); | |
codePush.sync({ | |
deploymentKey: CODEPUSH_STAGING_DEPLOYMENT_KEY, | |
installMode: codePush.InstallMode.ON_NEXT_RESTART, | |
}); | |
} else { | |
console.log('Syncing with production'); | |
codePush.sync({ | |
deploymentKey: CODEPUSH_PRODUCTION_DEPLOYMENT_KEY, | |
installMode: codePush.InstallMode.ON_NEXT_RESTART, | |
}); | |
} | |
}); | |
} | |
render() { | |
return <App />; | |
} | |
} | |
export default codePush(codePushOptions)(AppWrappedInCodePush); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment