程式碼功能:
判斷手機/平板是否安裝app
如果安裝則呼叫app的scheme,傳入url當作參數,來做後續操作
如果沒有安裝則跳到app store /google play 下載app
var. .location.search;
try{
openUrl = openUrl.substring(1,openUrl.length);
}catch(e){
}
var isiOS = navigator.userAgent.match('iPad')
|| navigator.userAgent.match('iPhone')
|| navigator.userAgent.match('iPod') , isAndroid = navigator.userAgent
.match('Android'),isDesktop = !isiOS&&!isAndroid;
if (isiOS) {
setTimeout(function () { window.location = "itms-apps: //itunes.apple.com/app/[name]/[id]?mt=8"; },25);
window.location = "[scheme]://[host]?url=" openUrl ;
}else if(isAndroid){
window.location = "intent://[host]/" "url=" openUrl "#Intent;scheme=[scheme];package=[package_name];end ";