|
|
@@ -116,12 +116,12 @@ async codePushUpdate() { |
|
|
|
versionInfo = this.state.versionInfo; |
|
|
|
}); |
|
|
|
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) |
|
|
|
).then((status: SyncStatus) => { |
|
|
|
console.warn(status); |
|
|
|
|
|
|
|
}, (error: any) => { |
|
|
|
CodePush.restartApp(); |
|
|
|
}); |
|
|
@@ -132,36 +132,27 @@ async codePushUpdate() { |
|
|
|
codePushStatusDidChange(syncStatus) { |
|
|
|
switch(syncStatus) { |
|
|
|
case CodePush.SyncStatus.CHECKING_FOR_UPDATE: |
|
|
|
console.warn("检查更新"); |
|
|
|
this.setState({ syncMessage: "检查更新" }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.DOWNLOADING_PACKAGE: |
|
|
|
console.warn("下载更新"); |
|
|
|
this.setState({ syncMessage: "下载更新" }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.AWAITING_USER_ACTION: |
|
|
|
console.warn("等待用户操作"); |
|
|
|
this.setState({ syncMessage: "等待用户操作" }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.INSTALLING_UPDATE: |
|
|
|
console.warn("安装更新"); |
|
|
|
this.setState({ syncMessage: "安装更新" }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.UP_TO_DATE: |
|
|
|
console.warn("已更新到最新程序"); |
|
|
|
this.setState({ syncMessage: "已更新到最新程序", updating: false }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.UPDATE_IGNORED: |
|
|
|
console.warn("更新被取消"); |
|
|
|
this.setState({ syncMessage: "更新被取消", updating: false }); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.UPDATE_INSTALLED: |
|
|
|
console.warn("更新已安装,重启应用后生效"); |
|
|
|
this.setState({ syncMessage: "更新已安装,重启应用后生效", updating: false }); |
|
|
|
CodePush.restartApp(); |
|
|
|
break; |
|
|
|
case CodePush.SyncStatus.UNKNOWN_ERROR: |
|
|
|
console.warn("未知错误"); |
|
|
|
this.setState({ syncMessage: "未知错误", updating: false }); |
|
|
|
break; |
|
|
|
} |
|
|
|