kfq00 2020-04-10
之前用ionic做了项目,学会了安卓打包,最近要做热更新,本来以为效果没出来,结果发现是我用的内网,哈哈哈哈,来来来,赶紧进入正题,把我的步骤分享给大家!!!!
1.在你的cordova项目下面添加cordova热更新插件
cordova plugin add cordova-hot-code-push-plugin
1.全局添加对应的cli插件
npm install -g cordova-hot-code-push-cli
3.执行 cordova-hcp init
λ cordova-hcp init Running init Please provide: Enter project name (required): jianianhua Please provide: Amazon S3 Bucket name (required for cordova-hcp deploy): Please provide: Path in S3 bucket (optional for cordova-hcp deploy): Please provide: Amazon S3 region (required for cordova-hcp deploy): (us-east-1) Please provide: IOS app identifier: Please provide: Android app identifier: Please provide: Update method (required): (resume) Please provide: Enter full URL to directory where cordova-hcp build result will be uploaded: 域名/cordovaHp/www/ Project initialized and cordova-hcp.json file created. If you wish to exclude files from being published, specify them in .chcpignore Before you can push updates you need to run "cordova-hcp login" in project directory
4.执行 cordova-hcp build 打个戳,控制台会输出相应信息。
λ cordova-hcp build // 下面是控制台输出信息 Running build Config { name: ‘jianianhua‘, ios_identifier: ‘‘, android_identifier: ‘‘, update: ‘resume‘, content_url: ‘域名/cordovaHp/www/‘, release: ‘2020.04.08-10.56.17‘ }
5.在cordova项目下面的config.xml文件下添加代码,和<access origin="*" />同级;url地址是你服务器放置chcp.json的地址,我这边是域名 + cordovaHp/www/chcp.json;插件会根据chcp.json里面的值来判断需不需要更新。
... <access origin="*" /> <chcp> <config-file url="域名 + cordovaHp/www/chcp.json" /> </chcp>
6.注意:
4.执行 cordova-hcp build 打个戳,控制台会输出相应信息。