APP的更新版本是通过以下函数获取的plus.runtime.getProperty(plus.runtime.appid, function(inf) {
alert(inf.version);
}
如下filename: "_doc/update/",务必不要更改这个filename,否则会提示安装成功,但是版本号一直没有变,其实就是install找不到这个文件就无法更新了plus.downloader.createDownload(data.wgt_url, {
filename: "_doc/update/"
}, function(d, status) {
if (status == 200) {
alert("下载wgt成功:" + d.filename);
install_app(d.filename); // 安装wgt包
} else {
console.log("下载wgt失败!");
}
}).start();
注意{force: true},务必写上这个参数plus.runtime.install(file_name, {force: true}, function() {
console.log("安装wgt文件成功!");
plus.nativeUI.alert("更新完成!", function() {
plus.runtime.restart();
});
}, function(e) {
console.log("安装wgt文件失败[" + e.code + "]:" + e.message);
});