var APPCommon = {
iphoneSchema: 'XingboTV://',
iphoneDownUrl: 'https://itunes.apple.com/cn/app/xing-botv-mei-nu-shuai-ge3d/id1098066581?l=en&mt=8',
androidSchema: 'scheme://com.xingbo/',
androidDownUrl: 'http://webrs.xingbo.tv/app/XingboLive-release.apk',
openApp: function() {
var this_ = this;
//微信
if(this_.isWeixin()) {
$(".weixin-tip").css("height", $(window).height());
$(".weixin-tip").show();
$('.weixin-tip').on('touchstart', function() {
$(".weixin-tip").hide();
});
} else { //非微信浏览器
if(navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
alert("iphone");
var loadDateTime = new Date();
window.setTimeout(function() {
var timeOutDateTime = new Date();
if(timeOutDateTime - loadDateTime < 5000) {
window.location = this_.iphoneDownUrl; //ios下载地址
} else {
window.close();
}
}, 25);
window.location = this.iphoneSchema;
} else if(navigator.userAgent.match(/android/i)) {
try {
window.location = this_.androidSchema;
setTimeout(function() {
window.location = this_.androidDownUrl; //android下载地址
}, 500);
} catch(e) {}
}
}
},
isWeixin: function() { //判断是否是微信
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
}
};
APPCommon.openApp();
apple 需要在前面添加
<meta name='apple-itunes-app' content='app-id=1098066581'>