|
|
@@ -82,6 +82,7 @@ let codePushOptions = { |
|
|
|
}; |
|
|
|
|
|
|
|
export default class MyPage extends Component { |
|
|
|
|
|
|
|
constructor(props) { |
|
|
|
super(props); |
|
|
|
this.state = { |
|
|
@@ -105,7 +106,7 @@ export default class MyPage extends Component { |
|
|
|
|
|
|
|
//更新函数 |
|
|
|
async codePushUpdate() { |
|
|
|
|
|
|
|
CodePush.allowRestart(); |
|
|
|
await CodePush.getUpdateMetadata(CodePush.UpdateState.RUNNING) |
|
|
|
.then((metadata: LocalPackage) => { |
|
|
|
this.setState({ versionInfo: metadata ? 'b'+NativeModules.BuildConfig.versionCode+"-" + metadata.label : 'b'+ NativeModules.BuildConfig.versionCode}); |
|
|
@@ -114,15 +115,16 @@ async codePushUpdate() { |
|
|
|
this.setState({ versionInfo: "Unknown"}); |
|
|
|
versionInfo = this.state.versionInfo; |
|
|
|
}); |
|
|
|
await CodePush.disallowRestart(); |
|
|
|
await CodePush.sync( |
|
|
|
{ mandatoryInstallMode: CodePush.InstallMode.IMMEDIATE, |
|
|
|
installMode: CodePush.InstallMode.IMMEDIATE}, |
|
|
|
{ mandatoryInstallMode: CodePush.InstallMode.ON_NEXT_RESTART, |
|
|
|
installMode: CodePush.InstallMode.ON_NEXT_RESTART}, |
|
|
|
this.codePushStatusDidChange.bind(this), |
|
|
|
this.codePushDownloadDidProgress.bind(this) |
|
|
|
); |
|
|
|
await CodePush.allowRestart(); |
|
|
|
|
|
|
|
).then((status: SyncStatus) => { |
|
|
|
|
|
|
|
}, (error: any) => { |
|
|
|
CodePush.restartApp(); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@@ -527,7 +529,7 @@ render() { |
|
|
|
return this.getAdView(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
MyPage = CodePush(codePushOptions)(MyPage); |
|
|
|
const styles = StyleSheet.create({ |
|
|
|
updatePage:{ |
|
|
|
flex: 2, |
|
|
@@ -892,5 +894,4 @@ render() { |
|
|
|
textDecorationLine: 'line-through', |
|
|
|
color : 'gray' |
|
|
|
}, |
|
|
|
|
|
|
|
}); |