appcenter codepush release-react -a <username>/<appname> -d Production
import React, {useEffect, useState} from 'react';
import {SafeAreaView, StyleSheet, Text, View} from 'react-native';
import codePush from 'react-native-code-push';
let codePushOptions = {checkFrequency: codePush.CheckFrequency.MANUAL};
function App() {
const [progress, setProgress] = useState(true);
useEffect(() => {
codePush.sync({
updateDialog: true,
installMode: codePush.InstallMode.IMMEDIATE,
});
}, []);
function codePushStatusDidChange(syncStatus) {
switch (syncStatus) {
case codePush.SyncStatus.CHECKING_FOR_UPDATE:
console.log('Checking for update.');
break;
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
console.log('Downloading package.');
break;
case codePush.SyncStatus.AWAITING_USER_ACTION:
console.log('Awaiting user action.');
break;
case codePush.SyncStatus.INSTALLING_UPDATE:
console.log('Installing update.');
setProgress(false);
break;
case codePush.SyncStatus.UP_TO_DATE:
console.log('App up to date.');
setProgress(false);
break;
case codePush.SyncStatus.UPDATE_IGNORED:
console.log('Update cancelled by user.');
setProgress(false);
break;
case codePush.SyncStatus.UPDATE_INSTALLED:
console.log('Update installed and will be applied on restart.');
setProgress(false);
break;
case codePush.SyncStatus.UNKNOWN_ERROR:
console.log('An unknown error occurred.');
setProgress(false);
break;
}
}
return (
<SafeAreaView style={{flex: 1}}>
<View style={styles.container}>
<Text style={styles.title}>Appcenter implementation</Text>
<Text style={styles.subtitle}>{`\u2022 CodePush Application`}</Text>
</View>
</SafeAreaView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'lightgreen',
justifyContent: 'center',
alignItems: 'center',
},
title: {
marginTop: 32,
fontSize: 35,
color: 'tomato',
},
subtitle: {
fontSize: 24,
fontWeight: '600',
color: 'blue',
},
});
export default codePush(codePushOptions)(App);