iOS

iOS - Supporting Associated Doma

2020-11-20  本文已影响0人  ienos

建立域名与应用程序之间的关联

下文中的 associated domain file(域名关联文件) 简写为 asf

// 应用场景

// 要求

// 原理

一、将 asf 上传到 website 上

下面是 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 whose fragment equals no_universal_links and instructs the system not to open it as a universal link"

               },

               {

                  "/": "/buy/*",

                  "comment": "Matches any URL whose path starts with /buy/"

               },

               {

                  "/": "/help/website/*",

                  "exclude": true,

                  "comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"

               },

               {

                  "/": "/help/*",

                  "?": { "articleNumber": "????" },

                  "comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"

               }

             ]

           }

       ]

   },

   "webcredentials": {

      "apps": [ "ABCDE12345.com.example.app" ]

   },

    "appclips": {

        "apps": ["ABCED12345.com.example.MyApp.Clip"]

    }

}

<Application Identifier Prefix> 见 App ID 中的 Prefix

image.png

asf 上传到 website 之后,需要的对应的下载链接格式如下: https://<fully qualified domain>/.well-known/apple-app-site-association [要求 https 带有有效证书和不重定向]

二、将相关域名添加到 App 中

image.png

如果需要匹配一个子域名,可以使用通配符 *

iOS 14 之后,App 将不再直接通过 website 获取 asf,而是通过发送请求到一个 Content Delivery Network(CDN) 做域名关联

如果是局域网通信,可以绕过 CDN 直接连接到域名,在 Associated Domains Entitlement 中添加参数 mode <service>:<fully qualified domain>?mode=<alternate mode>

Alternate Mode

上一篇 下一篇

猜你喜欢

热点阅读