ios Apple应用程序站点关联子域设置

2o7dmzc5  于 2023-04-08  发布在  iOS
关注(0)|答案(2)|浏览(246)

bounty将在2天后过期。回答此问题可获得+50声望奖励。vukojevicf正在寻找来自信誉良好的来源的答案

让我们试着做一个最有意义的例子来解释我的问题。假设我在example.com上有我的应用程序,并且还创建了一些通用链接,如example.com/application,当从手机设备点击时,如果安装了应用程序,则会在应用程序内打开。这很好用。
现在我可以创建子域,比如app.example.com,如果你点击它,它也会在应用程序中打开。所以如果安装了,几乎所有来自app.example.com/*的路径都应该在应用程序中打开。
这个过程是怎样的?我是否需要创建一个子域,是否可以通过添加关联域来完成,我的apple-app-site-association文件看起来会是什么样子?
我知道我的问题很模糊,但只是看看一些开始的指针或文档,希望这足以让人给予一些建议

u4vypkhs

u4vypkhs1#

我在我的apple-app-site-association文件中使用了这个JSON。

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "your appID and bundle identifier",
                "paths": ["*", "/*"]
            }
        ]
    }
}

你也可以检查这个例子(由苹果)在你的apple-app-site-association文件中添加子域。

{
  "applinks": {
      "details": [
           {
             "appIDs": [ "ABCDE12345.com.example.app", "ABCDE12345.com.example.app2" ],
             "components": [
               {
                  "#": "no_universal_links",
                  "exclude": true,
                  "comment": "Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link."
               },
               {
                  "/": "/buy/*",
                  "comment": "Matches any URL with a path that starts with /buy/."
               },
               {
                  "/": "/help/website/*",
                  "exclude": true,
                  "comment": "Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link."
               },
               {
                  "/": "/help/*",
                  "?": { "articleNumber": "????" },
                  "comment": "Matches any URL with a path that starts with /help/ and that has a query item with name 'articleNumber' and a value of exactly four characters."
               }
             ]
           }
       ]
   },
   "webcredentials": {
      "apps": [ "ABCDE12345.com.example.app" ]
   },

    "appclips": {
        "apps": ["ABCED12345.com.example.MyApp.Clip"]
    }
}

有关更多信息,您可以查看此链接:https://developer.apple.com/documentation/xcode/supporting-associated-domains

lskq00tm

lskq00tm2#

这是可能的。深层链接域和应用程序是多对多关系。您的每个域都应该提供关联清单,其中提到可以使用该域上的链接的每个应用程序。
如果您有两个域example.comapp.example.com以及一个应用程序,则这两个链接:

应该指向这样的文件(用实际的app id替换XXXXXXXXXX.com.example.app):

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appIDs": [
                    "XXXXXXXXXX.com.example.app"
                ],
                "paths": [
                    "*"
                ],
                "components": [
                    {"/": "/*"}
                ]
            }
        ]
    },
    "webcredentials": {
        "apps": [
            "XXXXXXXXXX.com.example.app"
        ]
    }
}

在您的iOS项目Entitlements.plist中,您应该显式添加每个域:

<plist version="1.0">
<dict>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
        <string>webcredentials:example.com</string>
        <string>applinks:app.example.com</string>
        <string>webcredentials:app.example.com</string>
    </array>
...

或使用通配符:

<plist version="1.0">
<dict>
    <key>com.apple.developer.associated-domains</key>
    <array>
        <string>applinks:example.com</string>
        <string>webcredentials:example.com</string>
        <string>applinks:*.example.com</string>
        <string>webcredentials:*.example.com</string>
    </array>
...

相关问题