通用链接在iOS 14设备上无法正常工作,但在模拟器上运行良好。

19
下面的解决方案可以在模拟器上支持UniversalLink。
我有一个支持UniversalLink的应用程序。用户点击网站上支持的链接,将被导航到应用程序中的功能。
但它在iOS 14 beta 4上无法正常工作。它不是打开应用程序,而是打开了一个网页。
经过研究,根据这里的文档所示 https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_associated-domains enter image description here 需要更新Service.entitlements以支持iOS 13和iOS 14。
<Key>com.apple.developer.associated-domains</key>
  <array>
    <string>applinks:hosturl</string>
    <string>applinks:hosturl?mode=developer</string>
 </array>

在模拟器上运行良好。 但我无法使其在设备上运行。 有人可以帮忙吗。

2个回答

40

如果您想在开发环境中打开应用程序,必须执行以下步骤:

步骤1:指定关联域名

服务:完全合格的域名?模式=备用模式

例如:applinks:YOUR_DOMAIN?mode=developer

步骤2:在设备上启用关联域名开发

在测试设备上,您需要激活关联域名开发设置,该设置位于:设置 -> 开发人员

设置

开发人员


1
我已经试图弄清楚它好几个小时了。谢谢。 - Onur Var
1
我也错过了在开发设置下启用关联域切换的步骤。谢谢! - jegadeesh

2
格式也已经改变适用于iOS14设备。这意味着,apple-app-site-association文件应该存在于您的网站根目录(如果支持预iOS9.3设备),并且存在于.well-known文件夹中。

<YOUR_URL>/apple-app-site-association
<YOUR_URL>/.well-known/apple-app-site-association

新的格式是为了支持 iOS14 之前和 iOS14 设备。
{
  "applinks": {
    "apps": [],
    "details": [
      {
        "appID": "<YOUR_APP_ID>",
        "components": [ // iOS14
          {
            "/": "<URL_PATH>",
            "comment": "Matches any URL whose path starts with URL_PATH and instructs the system not to open it as a universal link"
          }
        ],
        "paths": [ // pre iOS14
          "NOT \/api\/*",
          "NOT \/",
          "<URL_PATH>"
        ]
      }
    ]
  }
}

更多信息请参考: https://developer.apple.com/documentation/safariservices/supporting_associated_domains


2
除非您支持早于iOS 9.3的设备(我怀疑很少有这样的设备),否则您不需要将其放在两个位置。当时,苹果将默认关联位置更改为/.well-known/,因此您可以在well-known文件夹中使用一个文件,并包括两个路径和组件。请参见:https://developer.apple.com/forums/thread/43342 - Zack

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接