【问题标题】:UniversalLink is not working on iOS 14 devices, but works well on simulatorUniversalLink 不适用于 iOS 14 设备,但在模拟器上运行良好
【发布时间】:2020-08-20 08:00:26
【问题描述】:

以下方案可以在模拟器上支持universalLink。

我有一个支持 UniversalLink 的应用。 用户单击网站中支持的链接,将导航到应用程序中的功能。

但它无法在 iOS 14 beta 4 上运行。它没有打开应用程序,而是打开了一个网页 instread。

经过研究,我可以从这里的文档中看到 https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_developer_associated-domains

需要更新 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>

它在模拟器上运行良好。 但我无法让它在设备上运行。 任何人都可以提供帮助。

【问题讨论】:

    标签: ios swift ios-universal-links ios14


    【解决方案1】:

    如果您想在开发环境中打开应用程序,您必须:

    第 1 步:指定关联域

    service:fully qualified_domain?mode=alternate mode

    例如:applinks:YOUR_DOMAIN?mode=developer

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

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

    【讨论】:

    • 我已经想了好几个小时了。谢谢
    【解决方案2】:

    iOS14 设备的格式也发生了变化。 这意味着 apple-app-site-association 应位于您网站的根文件夹(适用于 iOS9.3 之前的设备,如果支持)以及 .well-known 文件夹。

    /apple-app-site-association
    /.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

    【讨论】:

    • 除非您支持 iOS 9.3 之前的设备(我怀疑很少有人支持),否则您不需要将它放在这两个位置。苹果当时将默认关联位置更改为/.well-known/,因此您可以使用知名文件夹中的一个文件,并且只包含路径和组件。见:developer.apple.com/forums/thread/43342
    • 谢谢,你拯救了我的一天
    【解决方案3】:

    指定关联域(完全限定域)

    示例:

         applinks:domain.com //  wrong 
    
    
         applinks:www.domain.com // right
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-28
      • 1970-01-01
      相关资源
      最近更新 更多