简体   繁体   English

iOS AppLinks 仅不适用于邮件应用程序

[英]iOS AppLinks only not working from mail app

We are in the progress of creating a new application and I'm facing some issues with the usage of app links.我们正在创建一个新的应用程序,我在应用程序链接的使用方面遇到了一些问题。

So I added the entitlements and I'm hosting the ".well-known/apple-app-site-association" file on my servers, that seems to be all good.所以我添加了权利,并且在我的服务器上托管了“.well-known/apple-app-site-association”文件,这似乎很好。

Then I'm testing the applinks by triggering them on my simulator using this command: /usr/bin/xcrun simctl openurl booted "https://links.domain.com/path/token" and nicely triggers my application.然后我通过使用以下命令在我的模拟器上触发它们来测试 applink: /usr/bin/xcrun simctl openurl booted "https://links.domain.com/path/token"并很好地触发了我的应用程序。

Then I started testing on real devices and all of the sudden it did not work anymore, I'm using the default mail app on these devices, and that is were the problem is.然后我开始在真实设备上进行测试,突然之间它不再起作用了,我在这些设备上使用默认邮件应用程序,这就是问题所在。

If I put the link inside a note (Notes app) it opens my app.如果我将链接放在笔记(笔记应用)中,它会打开我的应用。 If I open my email from the GMail app it launches my application, but that same exact email from the same gmail account but inside the Apple Mail app does not do a thing...如果我从 GMail 应用程序打开我的电子邮件,它会启动我的应用程序,但是来自同一个 Gmail 帐户但在 Apple Mail 应用程序内部的完全相同的电子邮件不会做任何事情......

I tried this right now both on iOS 13 and iOS14.我现在在 iOS 13 和 iOS14 上都尝试过这个。

The content of the hosted apple-app-site-association file looks like this:托管的 apple-app-site-association 文件的内容如下所示:

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "0000X0XXXX.com.domain.appname",
                "paths": ["*"]
            }
        ]
    },
    "webcredentials": {
        "apps": [ "0000X0XXXX.com.domain.appname" ]
    }
}

Any ideas on what we can try next would be welcome.欢迎任何关于我们下一步可以尝试的想法。 The only thing I can imagine is that the Mail app does some extra checks on whether your an app on the AppStore or not, but that would be a bit weird, no?!我唯一能想象的是邮件应用程序会额外检查您的应用程序是否在 AppStore 上,但这会有点奇怪,不是吗?!

Ok, I did find the issue and fix... It's not that hard actually and I bumped into it accidentally...好的,我确实找到了问题并修复了......实际上并没有那么难,我不小心撞到了它......

It seems that Apple does a really bad job in parsing HTML, in particular the href attribute of a link.似乎 Apple 在解析 HTML 方面做得非常糟糕,尤其是链接的href属性。 While I could not find any other client that behaves the same, it seems that if you don't put the scheme (http or https) in front of the url (so instead of https://google.com I was using just google.com) which you provide to the href attribute, then Apple makes something of it's own out of it: x-webdoc://30E09690-F388-4ED2-BB46-14DC829B974C/google.com .虽然我找不到任何其他行为相同的客户端,但似乎如果您不将方案(http 或 https)放在 url 前面(所以我使用的不是https://google.com ,而是 google .com),您将其提供给href属性,然后 Apple 会利用它自己制作一些东西: x-webdoc://30E09690-F388-4ED2-BB46-14DC829B974C/google.com I could spot this on the Apple Mail app, however on the iPhone where I was having the issue it was not even recognised as a link, so the behaviour seems to be a little different between their own apps.我可以在 Apple Mail 应用程序上发现这一点,但是在我遇到问题的 iPhone 上,它甚至未被识别为链接,因此它们自己的应用程序之间的行为似乎略有不同。

In the end it was my mistake for not putting https:// in front of my auto generated URI's.最后,我没有将https://放在我自动生成的 URI 前面是我的错误。 However I do think Apple does a poor job here in building the link HTML tag.但是我确实认为 Apple 在构建链接 HTML 标签方面做得很差。

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

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