|
本帖最后由 zjjay 于 2016-8-5 14:41 编辑
自从今年mam模块被苹果发现后一直没用在线更新,以致于之前判断版本是否最新失效....今天刚好写到这里只能这样子去判断了。如果有人有更好地方法直接在线更新请@一下我或者私信下我,谢谢! 代码如下(app id 数字随便拿了一个测试 493901993):
api.download({
url: "https://itunes.apple.com/lookup?id=493901993",
savePath: 'fs://iosversioninfo.txt',
cache: false
},function(ret, err){
var data = api.readFile({
sync: true,
path: 'fs://iosversioninfo.txt'
});
if(data){
var data = $api.strToJson(data);
//alert(data.results[0].version+" "+api.systemVersion)
if(data.results && data.results[0]){
if(data.results[0].version){
if(data.results[0].version!=api.systemVersion){
var content = data.results[0].currentVersionReleaseDate?data.results[0].currentVersionReleaseDate.replace("Z","").replace("T"," "):"";
var str = '新版本型号:' + data.results[0].version + ';更新内容:' + data.results[0].releaseNotes + ';发布时间:' + content;
api.confirm({
title : '有新的版本,是否下载并安装 ',
msg : str,
buttons : ['确定', '取消']
}, function(ret, err) {
if (ret.buttonIndex == 1) {
window.location.href = "itms-apps://itunes.apple.com/cn/app/jiu-jiu-jin/id493901993?mt=8";
}
});
}else{
api.toast({msg : "暂无新更新"})
}
}else{
api.toast({msg : "暂无新更新"})
}
}else{
api.toast({msg : "暂无新更新"})
}
}else{
api.toast({msg : "检测更新失败!"});
}
});
|
|