https://www.jianshu.com/p/cbef3659bf01
http://www.cocoachina.com/articles/13321
总结一下
1.ios9及以上版本,safari只能通过schema-href方式唤起app,其他浏览器如QQ浏览器可以通过href和iframe方式唤起
2.ios的safari可以不弹出打开app弹窗,提升用户体验,需要用Universal Links方式配置apple-app-site-association文件
3.微信环境,不能通过schema协议唤起app,需要Universal Links方式配置apple-app-site-association文件http://xxx.xxx.com/apple-app-site-association
代码
//schema
window.location.href = schemaUrl;
//iframe
function iframeBridge(url) {
let ifr = document.createElement("iframe");
ifr.src = url;
ifr.style.display = "none";
document.body.appendChild(ifr);
setTimeout(function () {
document.body.removeChild(ifr);
}, 1000);
};
let url = "schema://xxxxx"
let UA = navigator.userAgent;
if (navigator.userAgent.match(/(iPhone|iPod|iPad);?/i)) {
let iOS = UA.match(/(iPhone\sOS)\s([\d]+)/) || UA.match(/(iPad).*OS\s([\d_]+)/) || UA.match(/(iPod)(.*OS\s([\d_]+))?/);
let iOS9 = parseInt(iOS[2], 10);
if (iOS9 >= 9) {
window.location.href = url;
} else {
iframeBridge(url);
}
} else if (navigator.userAgent.match(/android/i)) {
iframeBridge(url);
}
//微信环境
UA.toLowerCase().match(/MicroMessenger/i) == 'micromessenger'