您的位置:首页 > 其它

Cordova 热更新处理(三):增加 listen 处理

2017-02-16 12:28 288 查看

20170123 热更新优化

1、给每个hot uopdate 产生的事件增加一个 listen
addEventListener 的 function 第一个参数总是 isTrusted:false,
第二个参数总数 undefined,以上 listen 没法统一在一起
待以后处理 addEventListener 的 function 参数
2、第一轮: apk 和 www 内容完全一样
sudo cordova-hcp build
sudo cordova build android
copy www 到 http://192.168.1.103/hot20170113/www sudo cordova run android
查看 logcat ,收到 chcp_nothingToUpdate,正常!logcat信息如下
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(72)] "收到事件 444666 events ===={"isTrusted":false}", source: file:///android_asset/www/js/index.js (72)
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(73)] "收到事件 444666 events ====undefined", source: file:///android_asset/www/js/index.js (73)
01-23 15:21:43.224: I/chromium(5088): [INFO:CONSOLE(74)] "收到事件 chcp_nothingToUpdate ====", source: file:///android_asset/www/js/index.js (74)
3、修改 index.html,
sudo cordova-hcp build
copy www 到 http://192.168.1.103/hot20170113/www 在手机退出程序,再次运行刚才的 app
查看 logcat ,收到 chcp_updateIsReadyToInstall,正常!logcat信息如下
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(86)] "收到事件 777666 events ===={"isTrusted":false}", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (86)
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(87)] "收到事件 777666 events ====undefined", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (87)
01-23 15:25:45.214: I/chromium(5088): [INFO:CONSOLE(88)] "收到事件 chcp_updateIsReadyToInstall ====", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.19.42/www/js/index.js (88)
4、退出app,再次进来app
** 现在 app 已经 update 到和 www 内容完全一样
查看 logcat ,收到 chcp_nothingToUpdate,正常!logcat信息如下
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(72)] "收到事件 444666 events ===={"isTrusted":false}", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (72)
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(73)] "收到事件 444666 events ====undefined", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (73)
01-23 15:28:49.636: I/chromium(5088): [INFO:CONSOLE(74)] "收到事件 chcp_nothingToUpdate ====", source: file:///data/user/0/io.cordova.hellocordova/files/cordova-hot-code-push-plugin/2017.01.23-15.25.31/www/js/index.js (74)
5、计划在 chcp_updateIsReadyToInstall 事件后,弹出提示,主动退出 app
*** 待下次处理
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  cordova ionic 热更新