H5頁面中喚醒app,版本問題可能導緻不生效,隻能說端太多,水太深
URL Scheme
1、建立一個隐藏的 iframe ,位址指向需要打開的url
// 在ios支援不好
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = url;
document.body.appendChild(iframe);
2、使用 window.location 或者 window.location.href 重新整理目前頁面
window.location.href = url;
3、建立一個隐藏的 a 标簽,位址指向打開的url,并觸發打開連結事件
var a = document.createElement('a');
a.style.display = 'none';
a.href = url;
document.body.appendChild(a);
a.click();
以上方法是隻是解決了在已安裝App裝置喚醒App的功能,并不能判斷是否已安裝App,沒有安裝即跳轉至下載下傳連結。
參考方案:
https://www.npmjs.com/package/callapp-lib參考文章
h5喚醒APP小記