react native code push 热更实现

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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值