简体   繁体   English

带有重定向的通用链接在 iOS 中不起作用

[英]Universal links with redirects not working in iOS

Company domain links end up in the iOS app.公司域链接最终出现在 iOS 应用中。 Links with redirects through MailChimp to company's website from email website end up in the iOS app.通过 MailChimp 从电子邮件网站重定向到公司网站的链接最终会出现在 iOS 应用程序中。

But links which redirect to company domain website through MailChimp tracking link tapped in mail app (Mail, Gmail etc) end up in Safari in company's web site.但是,通过邮件应用程序(Mail、Gmail 等)中点击的 MailChimp 跟踪链接重定向到公司域网站的链接最终会出现在公司网站的 Safari 中。

Is there any workaround to make MailChimp email links with redirect work as universal links and bring up the iOS app?是否有任何解决方法可以使具有重定向功能的 MailChimp 电子邮件链接用作通用链接并启动 iOS 应用程序?

I have actually developed a workaround for this. 我实际上为此开发了一种解决方法。

We created an app that had the function to allow a user to sign in by generating a magic access link. 我们创建了一个应用程序,其功能是允许用户通过生成魔术访问链接来登录。 The user would download and install the app, enter their email address and the server would send them an email containing a link in the form of: https://www.example.com/app/accesslink/ {{tokenHere}} 用户将下载并安装该应用程序,输入他们的电子邮件地址,服务器将向他们发送包含以下形式的链接的电子邮件: https ://www.example.com/app/accesslink/ {{tokenHere}}

We created an AASA file and uploaded it to our domain (www.example.com) for example :) https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html 我们创建了一个AASA文件,并将其上传到我们的域名(www.example.com),例如:) https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html

Most users could generate an access link fine, tap it and the app would load. 大多数用户可以生成一个访问链接,点击它,应用程序将加载。 We had handlers on the app to pick up the token and authenticate them etc. 我们在应用程序上有处理程序来获取令牌并对其进行身份验证等。

The problem came when some email providers rewrote the access link in the email. 当一些电子邮件提供商重写了电子邮件中的访问链接时出现问题。 This especially happened to corporate users who had URLblockers installed. 这尤其发生在安装了URLblocker的企业用户身上。

To work around this we created a rewrite rule on the server to rewrite www.example.com/app/accesslink/{{anythingHerer}} to a static file on the server called '404accesslink.html' (the filename is arbetary, the server was asp.net IIS in this case). 为了解决这个问题,我们在服务器上创建了一个重写规则,将www.example.com/app/accesslink/{{anythingHerer}}重写为服务器上名为'404accesslink.html'的静态文件(文件名是arbetary,服务器在这种情况下是asp.net IIS)。 We then edited the '404accesslink.html' as follows to include the following meta: 然后我们按如下方式编辑'404accesslink.html'以包含以下元数据:

<script>
    document.writeln('<meta name="apple-itunes-app" content="app-id={{APP_ID_HERE}}, app-argument=' + document.location.href + '">');
</script>

Because the file was served over a rewrite the location.href value was an exact match for the access link. 由于文件是通过重写提供的,因此location.href值与访问链接完全匹配。 This tricked iOS into opening the app and passing the path to it. 这诱骗iOS打开应用程序并将路径传递给它。 We could then pick it up in the handler as normal and authenticate the user. 然后我们可以正常地在处理程序中拾取它并验证用户身份。

We wrote some simple instructions in case opening the app wasn't automatic and the page was displayed (although in our tests this didn't happen). 我们写了一些简单的说明,以防打开应用程序不是自动的并且显示页面(尽管在我们的测试中这没有发生)。

<!DOCTYPE html>
<html>
<head>
  <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
  <script>
    document.writeln('<meta name="apple-itunes-app" content="app-id=XXXXXXXXXX, app-argument=' + document.location.href + '">');
  </script>
  <style>
    body {
        padding-top: 5%;
        color: #FFF;
        font-size: 1em;
        font-family: Arial, Helvetica, sans-serif;
        text-align: left;
        background: #00338D;
        margin: 50px;
    }
    h1 {
        font-weight: normal;
        font-size: 1.8em;
    }
    a {
        color: #FFF;
        font-weight: bold;
        text-decoration: none;
    }
  </style>
  <title>XXXXXXXXX</title>
  <body>
    <h1>Please select 'Open' in the app banner displayed at the top of this page to open the app with your access link.</h1>
    <p>If you do not see the app banner above then please close your browser and sign into the app using your email address and the password you used to register for the event.</p>
    <p>If you do not know your password then you can <a href="https://XXXXXXXXXXXXX/account/mobileforgot/">reset it by following this link</a>.</p>
    <p>Thank you,</p>
    <p>XXXXXXXXXXXXX team</p>
  </body>
</html>

The meta would probably be better if it was set and rendered server side as opposed to using JS client side, but it worked none the less. 如果设置和渲染服务器端而不是使用JS客户端,则meta可能会更好,但它仍然可以工作。

Before this was done: If any system rewrote/wrapped the app link the app wasn't associated with the new URL and when the user tapped the URL it was opened in Safari. 在此之前:如果任何系统重写/包装应用程序链接,则应用程序与新URL无关,并且当用户点击URL时,它在Safari中打开。

After this was done: If any system rewrote/wrapped the app link the app wasn't associated with the new URL and when the user tapped the URL it was opened in the app. 完成此操作后:如果任何系统重写/包装应用程序链接,则应用程序未与新URL关联,并且当用户点击URL时,它在应用程序中打开。

Universal Links are based on the actual URL of the link being opened. Universal Links基于正在打开的链接的实际URL。 This means if you wrap the link in a redirect (as MailChimp does), Universal Links won't function. 这意味着如果您将链接包装在重定向中(如MailChimp所做),Universal Links将无法运行。

To work around this, you'll need to disable click tracking on MailChimp. 要解决此问题,您需要在MailChimp上禁用点击跟踪 However, it may still not work in every app (Gmail, for example) if that app doesn't support Universal Links. 但是,如果该应用不支持通用链接,它可能仍然无法在每个应用(例如Gmail)中使用。

Branch.io (full disclosure: I'm on the Branch team) has been working with some of the larger email platforms to fix this issue and enable both Universal Links and click tracking, but up until this point MailChimp has not been interested. Branch.io (完全披露:我在分支团队)一直在与一些较大的电子邮件平台合作解决这个问题并启用通用链接和点击跟踪,但直到此时MailChimp一直没有兴趣。 Feel free to let them know this is something you would like to see! 随意让他们知道这是你想要看到的东西!

No, it's impossible. 不,这是不可能的。

The resource which work with associated links can consist apple-app-site-association file on public area. 使用相关链接的资源可以包含公共区域上的apple-app-site-association文件。 mail chimp doesn't have. 邮件黑猩猩没有。

https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html https://developer.apple.com/library/content/documentation/General/Conceptual/AppSearch/UniversalLinks.html

Adding support for universal links is easy. 添加对通用链接的支持很容易。 There are three steps you need to take: 您需要采取三个步骤:

Create an apple-app-site-association file that contains JSON data about the URLs that your app can handle. 创建一个apple-app-site-association文件,其中包含有关您的应用可以处理的网址的JSON数据。 Upload the apple-app-site-association file to your HTTPS web server. 将apple-app-site-association文件上传到您的HTTPS Web服务器。 You can place the file at the root of your server or in the .well-known subdirectory. 您可以将文件放在服务器的根目录或.well-known子目录中。 Prepare your app to handle universal links. 准备您的应用程序以处理通用链接。

Redirected deeplinks now work on iOS.重定向的深层链接现在适用于 iOS。 vanity url -> deeplink redirect -> opens app and stays there.虚 url -> 深层链接重定向 -> 打开应用程序并停留在那里。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM