使用mui开发混合app,上架app stroe后,监测app store是否有更新,并提示用户跳转app store更新应用。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
var ver; // 用于保存当前应用版本
mui.plusReady(function(){
plus.runtime.getProperty(plus.runtime.appid, function(inf) {
ver = inf.version; // 当前应用版本
var ua = navigator.userAgent.toLowerCase();
if(/iphone|ipad|ipod/.test(ua)) { // iphone
mui.ajax({
url: 'http://itunes.apple.com/lookup?id=1166765111',
type: "GET",
dataType: "json",
data: {
id: 1166765111
},
contentType:'application/x-www-form-urlencoded;charset=UTF-8',
success: function(res){
//console.log(JSON.stringify(res));
var version = res.results[0].version;
if(version > ver) {
mui.alert(res.results[0].releaseNotes, "版本更新", "确定", function() {
var url = 'itms-apps://itunes.apple.com/us/app/id1166765111';
plus.runtime.openURL(url);
})
}
}
})
}
});
});