验证中...
10月20日,北京【人工智能】源创会火热报名中,点击报名收获 AI 训练指南
片段 1 片段 2
index.ios.js
原始数据 复制代码
import React, { Component } from "react";
import {
AppRegistry,
Dimensions,
Image,
StyleSheet,
Text,
TouchableOpacity,
View
} from "react-native";
import CodePush from "react-native-code-push";
class CodePushDemo extends Component {
constructor() {
super();
console.log("===start===");
this.state = {
restartAllowed: true
};
}
codePushStatusDidChange(syncStatus) {
switch(syncStatus) {
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
this.setState({ syncMessage: "Checking for update." });
break;
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
this.setState({ syncMessage: "Downloading package." });
break;
case CodePush.SyncStatus.AWAITING_USER_ACTION:
this.setState({ syncMessage: "Awaiting user action." });
break;
case CodePush.SyncStatus.INSTALLING_UPDATE:
this.setState({ syncMessage: "Installing update." });
break;
case CodePush.SyncStatus.UP_TO_DATE:
this.setState({ syncMessage: "App up to date.", progress: false });
break;
case CodePush.SyncStatus.UPDATE_IGNORED:
this.setState({ syncMessage: "Update cancelled by user.", progress: false });
break;
case CodePush.SyncStatus.UPDATE_INSTALLED:
this.setState({ syncMessage: "Update installed and will be applied on restart.", progress: false });
break;
case CodePush.SyncStatus.UNKNOWN_ERROR:
this.setState({ syncMessage: "An unknown error occurred.", progress: false });
break;
}
}
codePushDownloadDidProgress(progress) {
this.setState({ progress });
}
render() {
let progressView;
if (this.state.progress) {
progressView = (
<Text style={styles.messages}>{(this.state.progress.receivedBytes / 1024).toFixed(2)} of {(this.state.progress.totalBytes / 1024).toFixed(2)} KB received</Text>
);
}
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to CodePush!!!
</Text>
<Text style={styles.welcome}>
Test0
</Text>
{progressView}
<Image style={styles.image} resizeMode={Image.resizeMode.contain}
source={require("./images/rank_01.png")}/>
<Text style={styles.messages}>{this.state.syncMessage || ""}</Text>
</View>
);
}
componentDidMount() {
console.log("===end===");
CodePush.sync(
{},
this.codePushStatusDidChange.bind(this),
this.codePushDownloadDidProgress.bind(this)
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: "center",
backgroundColor: "#F5FCFF",
paddingTop: 50
},
image: {
margin: 30,
width: Dimensions.get("window").width - 100,
height: 365 * (Dimensions.get("window").width - 100) / 651,
},
messages: {
marginTop: 30,
textAlign: "center",
},
welcome: {
fontSize: 20,
textAlign: "center",
margin: 20
},
});
/**
* Configured with a MANUAL check frequency for easy testing. For production apps, it is recommended to configure a
* different check frequency, such as ON_APP_START, for a 'hands-off' approach where CodePush.sync() does not
* need to be explicitly called. All options of CodePush.sync() are also available in this decorator.
*/
let codePushOptions = { checkFrequency: CodePush.CheckFrequency.ON_APP_START };
CodePushDemo = CodePush(codePushOptions)(CodePushDemo);
AppRegistry.registerComponent("CodePushDemo", () => CodePushDemo);
20180113190716869.png

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助