Skip to content

Instantly share code, notes, and snippets.

@naishe
Created August 4, 2020 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save naishe/044ac7f2a80a4afa35ddb88b33b42af5 to your computer and use it in GitHub Desktop.
Save naishe/044ac7f2a80a4afa35ddb88b33b42af5 to your computer and use it in GitHub Desktop.
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