簡體   English   中英

是否可以瀏覽應用程序的深層鏈接? (沒有彈出窗口)

[英]Is it possible to browser deeplink to an app? (without popup)

我正試圖從瀏覽器深入鏈接到一個應用程序,這工作正常。 但問題是,iOS正在顯示“Safari無法打開頁面”,然后重定向到應用商店(后備解決方案)。

是否有可能制作一些JS魔法,以便不出現彈出框?

這是代碼:

    var now = new Date().valueOf();
    setTimeout(function () {
        if (new Date().valueOf() - now > 100) return;
        window.location = "https://itunes.apple.com/us/app/twitter/id333903271?mt=8";
    }, 10);
    window.location = "twitter://timeline";

我在一段時間后遇到了類似的情況,我認為最好的辦法是擁有一個iframe並為它提供一個來源。

function mobileDeepLink() {
    var iframe = document.createElement('iframe');
    iframe.src = "twitter://timeline";

    // hide iframe visually
    iframe.width = 0;
    iframe.height = 0;
    iframe.frameBorder = 0;

    var now = new Date().valueOf();
    setTimeout(function () {
        if (new Date().valueOf() - now > 100) return;
        window.location = "https://itunes.apple.com/us/app/twitter/id333903271?mt=8";
    }, 10);

    // Append it to the body.
    document.body.appendChild(iframe);
    iframe.parentNode.removeChild(iframe);
}

mobileDeepLink();

這樣,當找不到方案時,您將看不到錯誤彈出窗口。

更新

這種方法僅適用於IOS 8及更低版本。 從IOS 9及更高版本開始,使用通用鏈接本地支持深度鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM