DylanNee
DylanNee
  • 发布:2015-10-05 16:46
  • 更新:2015-10-12 19:16
  • 阅读:2207

关于APP自动更新,IDE打包WGT,IOS更新成功,安卓更新却变成了wgtu

分类:Native.js

利用IDE工具打包WGT更新包。判断代码:

var wgtVer = null;  
 // 检测更新  
var checkUrl = "http://aqm.oss-cn-hangzhou.aliyuncs.com/app-Version.html";  
// 下载wgt文件  
var wgtUrl = "http://aqm.oss-cn-hangzhou.aliyuncs.com/appUpdate.wgt";  

//检测plus状态并且确认连接WIFI后自动更新  
if (window.plus && plus.networkinfo.getCurrentType()==plus.networkinfo.CONNECTION_WIFI) {  
    plusReady();  
} else {  
    document.addEventListener('plusready', plusReady, false);  
}  

function plusReady() {  
    // ......  
    // 获取本地应用资源版本号  
    plus.runtime.getProperty(plus.runtime.appid, function(inf) {  
        wgtVer = inf.version;  
        console.log("当前应用版本:" + wgtVer);  
        checkUpdate();  
    });  
}  

function checkUpdate() {  
        var xhr = new XMLHttpRequest();  
        xhr.onreadystatechange = function() {  
            switch (xhr.readyState) {  
                case 4:  
                    plus.nativeUI.closeWaiting();  
                    if (xhr.status == 200) {  
                        console.log("检测更新成功:" + xhr.responseText);  
                        var newVer = xhr.responseText;  
                        if (wgtVer && newVer && (wgtVer != newVer )) {  
                            plus.nativeUI.confirm("是否要安装新的程序?",  
                                function(e) {  
                                    if(e.index==1){downWgt();}  
                                },  
                            "",['取消','确定']  
                            );  
                        } else {  
                            console.log("无新版本可更新!");  
                        }  
                    } else {  
                        console.log("检测更新失败!");  
                    }  
                    break;  
                default:  
                    break;  
            }  
        }  
        xhr.open('GET', checkUrl);  
        xhr.send();  
    }  

function downWgt() {  
        plus.nativeUI.showWaiting("系统更新中");  
        plus.downloader.createDownload(wgtUrl, {  
            filename: "_doc/update/"  
        }, function(d, status) {  
            if (status == 200) {  
                console.log("下载wgt成功:" + d.filename);  
                installWgt(d.filename); // 安装wgt包  
            } else {  
                console.log("下载wgt失败!");  
            }  
            plus.nativeUI.closeWaiting();  
        }).start();  
    }  
    // 更新应用资源  

function installWgt(path) {  
    plus.nativeUI.showWaiting("正在更新程序...");  
    plus.runtime.install(path, {}, function() {  
        plus.nativeUI.closeWaiting();  
        console.log("安装wgt文件成功!");  
        plus.nativeUI.confirm("更新成功,是否重启?",  
            function(e) {  
                if(e.index==1){plus.runtime.restart();}  
            },  
            "",['取消','确定']  
        );  
    }, function(e) {  
        plus.nativeUI.closeWaiting();  
        plus.nativeUI.alert("更新失败[" + e.code + "]:" + e.message);  
    });  
}

IOS更新成功,安卓更新的时候却提醒:WGTU更新失败,manifest.json不在www目录下。这是什么情况?我明明打包的是WGT。为什么安卓更新却变成了差量更新?

2015-10-05 16:46 负责人:无 分享
已邀请:
DylanNee

DylanNee (作者)

WGT地址是我模拟的。

DylanNee

DylanNee (作者)

没人回答这个问题么?

DylanNee

DylanNee (作者)

???没人碰到这个问题么?

该问题目前已经被锁定, 无法添加新回复