最近用ionic 3 作的app业务作的差很少了,忽然想到之后app若是有更新该怎么搞?想到咱们的app后期更新应该不大,,最多就是改改bug和增长下用户体验,若是只有一些小的更新,而后提交各个应用商店,须要长时间的审核...鉴于咱们制做android平台,再而咱们用的技术是前端3大件:html,css和js,所以我计划用热更新来搞.css
ionic热更新有两个插件:html
cordova-hot-code-push ionic 官方推荐的插件(正好还有一篇教程)
前端
这两篇教程写的已经很是详细了,我感受我都没有写的必要了.我采用第二个插件完成的个人需求,主要缘由是:2个插件都支持远程服务器托管你的更新,你只需注册远程认证,经过命令行输入验证而且上传到远程服务器,来进行更新.可是第二个插件支持手动更新资源,将文件放在本身的服务器.具体采用哪一种方式实现热更新取决于你的喜爱了.android
下面我来记录我在使用中遇到的问题:git
han@ubuntu:~/project/zero_app$ ionic cordova plugin add cordova-hot-code-push > cordova plugin add cordova-hot-code-push --save Error: Not found : cordova-hot-code-push [ERROR] An error occurred while running subprocess cordova. cordova plugin add cordova-hot-code-push --save exited with exit code 1. Re-running this command with the --verbose flag may provide more information. han@ubuntu:~/project/zero_app$ cordova plugin add cordova-hot-code-push-plugin Installing "cordova-hot-code-push-plugin" for android Installing dependency packages:
ionic官方文档中提供的方法不行,使用 cordova plugin add cordova-hot-code-push-plugin 命令就能够了.github
我采用了教程默认的 now 方式,可是正式版确定不能是 now ,我想用 cordova-hot-code-push-cli 插件来修改,我没找到解决方法,只能使用最原始的方法,使用 cordova-hcp init 从新生成一份配置:json
han@ubuntu:~/project/zero_app$ cordova-hcp init Running init Please provide: Enter project name (required): zero app 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: cn.swifthealth.zeroapp Please provide: Android app identifier: cn.swifthealth.zeroapp Please provide: Update method (required): (resume) start Please provide: Enter full URL to directory where cordova-hcp build result will be uploaded: http://192.168.1.81:8000/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
为了我开发方便,我使用了自动更新和自动安装,配置在congif.xml中ubuntu
<chcp> <auto-download enabled="true" /> <auto-install enabled="true" /> <config-file url="http://192.168.1.81:8000/www/chcp.json" /> </chcp>
自动安装更新确定是不合适的,用户会感受到本身被耍了,好好的使用着,在下次启动的时候跟上次同样了...我会在之后修改成让用户自动选择.swift