if(Platform.OS=='android'){
deploymentKey = '============'
}else if (Platform.OS=='ios'){
deploymentKey = '========'
}
CodePush.allowRestart();
CodePush.checkForUpdate(deploymentKey).then((update) => {
if (!update) {
console.log("codepush-----已是最新版本--");
hasNew = false;
this.checkShowRecharge();
} else {
hasNew = true;
console.log("codepush-----不是最新版本--");
CodePush.sync({
deploymentKey: deploymentKey,
updateDialog: false,
installMode: CodePush.InstallMode.IMMEDIATE,
},
(status) => {
switch (status) {
case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
console.log("codepush-----正在下载");
break;
case CodePush.SyncStatus.INSTALLING_UPDATE:
console.log("codepush-----正在安装.");
break;
case CodePush.SyncStatus.UP_TO_DATE:
console.log("codepush-----更新完成");
this.checkShowRecharge();
break;
case CodePush.SyncStatus.UPDATE_INSTALLED:
console.log("codepush-----已经安装.");
this.checkShowRecharge();
break;
case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
console.log("codepush-----查询更新.");
break;
case CodePush.SyncStatus.UPDATE_IGNORED:
console.log("codepush-----提示更新后,用户选择了忽视.");
break;
}
},
(progress) => {
console.log('progress.receivedBytes----------',progress.receivedBytes);
console.log('progress.receivedBytes----------',progress.totalBytes)
this.setState({
nowSize:progress.receivedBytes,
totalSize:progress.totalBytes
})
}
);
}
})
CodePush.notifyAppReady();//不要忘记 否则会回滚
热更推送
code-push release-react Mtest android --t 1.2.3 --dev false --d Production --des "1. sss\n 2. ttt"
code-push release-react MtestIOS ios --t 1.0.21 --dev false --d Production --des "1.优化操作流程" --m true