iOS 通用链接在 Safari 中无法使用,但在其他地方都可以使用

标签 ios ios-universal-links

我成功地使通用链接在我们的应用程序中的工作达到 99% 的完美,但我仍在努力使其在 Safari 中可靠地工作。

这就是发生的事情:

  • 如果我从 Gmail 中的 www 域或非 www 域获得链接,两者都会正确启动应用程序;

  • 如果我在 Notes 中写入来自 www 或非 www 域的 URL,则两者都会正确启动应用程序;

  • 在 Safari/Chrome 中,只有来自非 www 域的链接才能 100% 可靠地启动应用程序;

  • 在 Safari/Chrome 中,www 版本的链接有时会启动应用程序,但总是在第一次点击后停止工作;

  • 在 Safari 中,如果我长按 www 版本的链接,它会显示“在应用程序中打开”上下文选项;

  • 我将我们的应用程序配置为处理 wwww 和非 www 域;我们使用 React Native/Expo,所以这就是我们在 ios.linkedDomains 下的内容:

"associatedDomains": [
        "applinks:www.mydomain.com",
        "applinks:mydomain.com"
      ]

关于 AASA,它位于 /.well-known/apple-app-site-association 并正确返回上下文类型 (json):

{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appIDs": ["MYTEAMID.com.ourcompany.ourfirstapp"],
        "components": [
          {
            "/": "/first-app/path",
            "comment": "Matches any URL whose path starts with /first-app/path"
          }
        ]
      },
      {
        "appID": "MYTEAMID.com.ourcompany.ourfirstapp",
        "paths": [ "/first-app/path" ]
      },
      {
        "appIDs": ["MYTEAMID.com.ourcompany.oursecondapp"],
        "components": [
          {
            "/": "/second-app",
            "comment": "Matches any URL whose path starts with /second-app"
          }
        ]
      },
      {
        "appID": "MYTEAMID.com.ourcompany.oursecondapp",
        "paths": [ "/second-app" ]
      }
    ]
  },
  "activitycontinuation": {
    "apps": [
      "MYTEAMID.com.ourcompany.ourfirstapp",
      "MYTEAMID.com.ourcompany.oursecondapp"
    ]
  }
}

我目前不知道如何修复 www 域链接的 safari/chrome 行为。

最佳答案

终于找到答案了。引用 Branch 文档:

Universal Links will not work with a user-driven element click on the same domain. For example, if there is a Universal Link on google.com pointing to a different Universal Link on google.com, it will not open the app.

就我而言,不起作用的 www 链接是从我在同一 www 域中托管的页面链接的,因此它们根本不起作用。

关于iOS 通用链接在 Safari 中无法使用,但在其他地方都可以使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66236706/

相关文章:

objective-c - 在 switch 语句中达到默认值后 EXC BAD ACCESS

iOS 通用链接 : Tapping universal link inside the Application redirects me to safari instead of continuing in the application

iOS 10.3 通用链接不工作

ios ->= 400 错误代码与 apple-app-site-association json 文件

ios - iOS 上的 GMail 应用程序使用什么来编辑 HTML 电子邮件?

ios - 无法运行 `sigh` faSTLane

ios - CKAsset 不会显示在表格 View 图像中

ios - 使用 WatchConnectivity 框架的独立 watch 应用程序

ios - 如何支持相同应用程序但不同环境的通用链接?

ios - 刷新关联域 iOS