ios离线打包之后,在线更新wgt文件,更新完版本号不变。然后就会继续下载安装,第二次安装会报安装文件失败[-1205]:wgt安装包中manifest.json文件的version要高于现有版本号。请问应该怎么解决呢?下面是更新代码,用的是官方给的
mui.plusReady(function(){
// 检查更新
plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo){
var appversion=wgtinfo.version;
appversiondata=plus.os.name+appversion;
capajax({
type:"get",
url:url,
success:function(data){
if(data.Version){
if(data.Version>appversion){
// plus.nativeUI.showWaiting("发现新版本~正在下载更新,\n请耐心等待。更新内容:\n"+data.UpdateContent,{back:"none"})
downLoad(data,data.UpdateContent);
}else{
}
};
}
})
});
}
})
//下载新版本
function downLoad(ver,UpdateContent){
if(ver.UpdateApk&&ver.UpdateApk.indexOf('apk')>0){
if(plus.os.name=='Android'){
var fileName="version."+ver.UpdateApk;
}else if(plus.os.name=='iOS'){
plus.runtime.openURL("xxx");
return;
}
}else{
if(plus.os.name=='Android'){
var fileName="version."+ver.Version+'.wgt';
}else if(plus.os.name=='iOS'){
var fileName="version.IOS."+ver.Version+'.wgt';
}
}
plus.nativeUI.showWaiting("发现新版本~正在下载更新,\n请耐心等待。更新内容:\n"+UpdateContent,{back:"none"})
plus.downloader.createDownload(url_+'/apk/'+fileName, {
filename: ""
}, function(d, status) {
plus.nativeUI.closeWaiting();
if(status == 200) {
alert(d.filename)
installWgt(d.filename); // 安装
} else {
mui.toast("下载安装包失败!",{type:"div"});
}
}).start();
}
function installWgt(path){
plus.nativeUI.showWaiting("安装更新包...",{back:"none"});
plus.runtime.install(path, {}, function() {
plus.nativeUI.showWaiting("应用资源更新完成!");
alert(path)
if(path.indexOf('wgt')>0){
plus.nativeUI.closeWaiting();
alert('重启')
plus.runtime.restart();
}else{
plus.runtime.quit();
}
}, function(e) {
plus.nativeUI.closeWaiting();
mui.alert("安装文件失败[" + e.code + "]:" + e.message, "提示", "确定", "", 'div');
});
}
非常感谢!!
devh5
qq群不存在??!!
2019-03-20 10:52
DCloud_iOS_XHY
回复 devh5:群号没问题呀,你再申请一下试试看,注意是群,不是用户
2019-03-20 11:50