Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Integrating CodePush Advanced: 1
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