简体   繁体   English

是否可以浏览应用程序的深层链接? (没有弹出窗口)

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

I'm trying to deeplink into an app from the browser, that's working fine. 我正试图从浏览器深入链接到一个应用程序,这工作正常。 But the problem is, that iOS is showing a "Safari can't open the page" and then redirects to the app store (fallback solution). 但问题是,iOS正在显示“Safari无法打开页面”,然后重定向到应用商店(后备解决方案)。

Is it possible to make some JS magic, so that popup box doesn't appear? 是否有可能制作一些JS魔法,以便不出现弹出框?

Here is the code: 这是代码:

    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";

I encountered a similar scenario some time back and I figured the best way to go about is have an iframe and provide a source to it.. 我在一段时间后遇到了类似的情况,我认为最好的办法是拥有一个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();

That way you would not see the error popup when the scheme cannot be found. 这样,当找不到方案时,您将看不到错误弹出窗口。

Update 更新

This approach will only work for IOS 8 and lower. 这种方法仅适用于IOS 8及更低版本。 From IOS 9 and later, deep linking is being supported natively using universal links. 从IOS 9及更高版本开始,使用通用链接本地支持深度链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在没有浏览器的情况下显示弹出窗口 - How to show a popup without a browser 是否可以在不捆绑浏览器的情况下构建独立的HTML5 App *? - Is it possible to build a standalone HTML5 App *without* bundling a browser? 深层链接到 Facebook 应用程序(使用 fb: 协议)在 Facebook 应用程序内浏览器中不起作用 - Deeplink to Facebook App (using fb: protocol) not working from Facebook in-app browser 重定向到浏览器中没有弹出菜单的链接 - Redirect to a Link without Popup Menu in Browser 没有浏览器,是否可以进行ajax调用? - Are ajax calls possible without a browser? 从外部深度链接到Ember应用 - Deeplink to Ember app from outside 如何处理深度链接重定向无法跨浏览器 - How to handle deeplink redirect fails cross browser Branch.io深度链接在我的浏览器中不起作用 - Branch.io deeplink not working in my browser 以编程方式确定是否在浏览器中启用了弹出窗口阻止程序,而无需打开新选项卡 - programmatically determine if the popup blocker is enabled in a browser without opening the new tab 打开新窗口,浏览器不会发出弹出窗口的警告 - open new window without the browser giving warning that is a popup
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM