/ *
- Created by Zhuoyuan on 2018 16
*
* /
import React, {Component} from "react";
import {
StyleSheet,
Text,
View,
TouchableOpacity,
Alert
} from "react-native";
import codePush from "react-native-code-push";
type Props = {};
class App extends Component < Props > {
componentDidMount() {
this.codePushUpdate()
}
/**
*
* IMMEDIATE(0) //
* ON_NEXT_RESTART(1) //
* ON_NEXT_RESUME(2) //
*/
codePushUpdate() {
codePush.sync({
installMode: codePush.InstallMode.IMMEDIATE,
updateDialog: true
},
(status) => {
switch (status) {
case codePush.SyncStatus.CHECKING_FOR_UPDATE:
alert("codePush.SyncStatus.CHECKING_FOR_UPDATE");
break;
case codePush.SyncStatus.AWAITING_USER_ACTION:
alert("codePush.SyncStatus.AWAITING_USER_ACTION");
break;
case codePush.SyncStatus.DOWNLOADING_PACKAGE:
alert("codePush.SyncStatus.DOWNLOADING_PACKAGE");
break;
case codePush.SyncStatus.INSTALLING_UPDATE:
alert("codePush.SyncStatus.INSTALLING_UPDATE");
break;
case codePush.SyncStatus.UP_TO_DATE:
alert("codePush.SyncStatus.UP_TO_DATE");
break;
case codePush.SyncStatus.UPDATE_IGNORED:
alert("codePush.SyncStatus.UPDATE_IGNORED");
break;
case codePush.SyncStatus.UPDATE_INSTALLED:
alert("codePush.SyncStatus.UPDATE_INSTALLED");
break;
case codePush.SyncStatus.SYNC_IN_PROGRESS:
alert("codePush.SyncStatus.SYNC_IN_PROGRESS");
break;
case codePush.SyncStatus.UNKNOWN_ERROR:
alert("codePush.SyncStatus.UNKNOWN_ERROR");
break;
}
},
({receivedBytes, totalBytes,}) => {
alert("receivedBytes / totalBytes: ------------ " + receivedBytes + "/" + totalBytes);
}
);
}
/**
*
*/
onButtonPress = () => {
codePush.sync({
updateDialog: true,
installMode: codePush.InstallMode.IMMEDIATE
});
};
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native CodePush2.1!
</Text>
<Text style={styles.instructions}>
!
</Text>
<TouchableOpacity onPress={this.onButtonPress}>
<Text>Check for updates</Text>
</TouchableOpacity>
</View>
);
}
}
const styles = StyleSheet.create ({
)container: {
flex: 1,
justifyContent: "center",
alignItems: "center",
backgroundColor: "-sharpF5FCFF",
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 10,
},
instructions: {
textAlign: "center",
color: "-sharp333333",
marginBottom: 5,
},
});
export default codePush (App);
the last line of code is changed later, and it is still invalid before it is direct export default class. There is no last line of code
bundle successfully released to Microsoft server
after opening app,
pops up codePush.SyncStatus.CHECKING_FOR_UPDATE and codePush.SyncStatus.UP_TO_DATE
respectively, but the page does not change. The new bundle I posted to the server is a solution to change ui
Thank you