深度链接后备 [英] Deep Link Fallback

查看:89
本文介绍了深度链接后备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将发布指向Facebook和Twitter的链接,以获取进入我的应用程序的深层链接。我已经开始使用Facebook进行测试,并且只要安装了Facebook应用程序,我的链接就可以正常工作。如果他们没有安装Facebook应用程序,则会直接进入我的网站。

I will be posting links to Facebook and Twitter for deep links into my app. I have started to test with Facebook and my link works as long as the Facebook app is installed. If they don't have the Facebook app installed, they're just taken to my website.

如果用户没有已安装Facebook应用程序或更普遍地单击了我应用程序的链接,我总是希望将它们发送到我的应用程序中吗?

What is best practice for handling fallback if the user doesn't have the Facebook app installed or more generally clicks on a link for my app and I always want them sent into my app?

推荐答案

好问题。您不应共享直接引向您应用的深层链接,而应在网站上托管带有Java备用代码的网页。该页面可以直接打开应用程序,也可以退回到App Store(而不是您的网站)。

Great question. Rather than sharing a deep link that leads directly to your app, you should host a page on your website with fallback code in Javascript. That page can either open the app directly or fall back to the App Store (rather than your website).

以下是您需要托管的页面的具体示例在您的服务器上并链接到Facebook。它也适用于电子邮件,社交媒体等。只需替换您应用的URI 您应用的应用商店链接。请注意,iframe可在更多浏览器上使用。

Here is a concrete example of the page you would need to host on your server and link to on Facebook. It also works for emails, social media, etc. Simply substitute in your app's URI and your app's App Store link. Note that the iframe works on a greater number of browsers.

<!DOCTYPE html>
<html>
    <body>
        <script type="text/javascript">
            window.onload = function() {
                // Deep link to your app goes here
                document.getElementById("l").src = "my_app://";

                setTimeout(function() {
                    // Link to the App Store should go here -- only fires if deep link fails                
                    window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
                }, 500);
            };
        </script>
        <iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>
    </body>
</html>

因此,如果用户安装了您的应用,则带有URI的链接将成功,并且用户将请先离开浏览器,然后才能触发重定向到App Store的脚本。如果用户没有您的应用程序,则重定向成功(出现简短错误消息后)。

So, if the user has your app installed, the link with the URI will succeed and the user will leave the browser before the script for redirecting to the App Store can be triggered. If the user does not have your app, the redirect succeeds (after a brief error message).

披露:我是分支指标,以上代码是我们针对此问题的解决方案的一部分。

Disclosure: I'm a developer at the Branch Metrics and the above code is part of our solution to this issue.

这篇关于深度链接后备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆