如何在服务器上为iOS应用程序上传文件apple-app-site-association以进行通用链接? [英] How to upload file apple-app-site-association for universal linking in server for iOS app?

查看:329
本文介绍了如何在服务器上为iOS应用程序上传文件apple-app-site-association以进行通用链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在服务器中上传 apple-app-site-association 文件的步骤是什么。 stg1.example.com是需要完成通用链接的网站,文件应该在其根路径中上传。如何在iOS中上传服务以进行通用链接。如何在服务器中上传 json 格式的文件?

What is the procedure to upload apple-app-site-association file in server. stg1.example.com is website where universal linking need to be done and file should be uploaded in the root path of it.How to make the service to upload for universal linking in iOS . How to upload the json formatted file in the server ?

推荐答案

apple-app-site-association 文件需要是可通过 https://stg1.example.com/apple-app-site-association 通过 HTTPS 访问,无需任何重定向。

The apple-app-site-association file needs to be accessible via HTTPS, without any redirects, at https://stg1.example.com/apple-app-site-association.

该文件如下所示:

{
"applinks": {
    "apps": [ ],
    "details": [
        {
            "appID": "{app_prefix}.{app_identifier}",
            "paths": [ "/path/to/content", "/path/to/other/*", "NOT /path/to/exclude" ]
        },
        {
            "appID": "TeamID.BundleID2",
            "paths": [ "*" ]
        }
    ]
}
}

示例

demo file in example

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "M8HBL5W4VV.com.Universal-Links",
                "paths": [ "/iOS-Universal-Links/*"]
            }
        ]
    }
}

注意 - 不要追加 .json apple-app-site-association 文件名。

NOTE - Don’t append .json to the apple-app-site-association filename.

密钥如下:

apps :应该有一个空数组作为其价值,它必须存在。这就是Apple想要它的方式。

详细信息:是一个字典数组,一个是网站支持的每个iOS应用程序。每个字典都包含有关应用程序,团队和软件包ID的信息。

The keys are as follows:
apps: Should have an empty array as its value, and it must be present. This is how Apple wants it.
details: Is an array of dictionaries, one for each iOS app supported by the website. Each dictionary contains information about the app, the team and bundle IDs.

有三种方法可以定义路径:

静态:整个支持的路径被硬编码以识别特定链接,例如/ static / terms

通配符:A *可用于匹配动态路径,例如/ books / *可以匹配任何作者页面的路径。 ?特定路径组件内部,例如,书籍/ 1?可用于匹配ID以1开头的任何书籍。

排除:在NOT前面添加路径以排除该路径的匹配。

There are 3 ways to define paths:
Static: The entire supported path is hardcoded to identify a specific link, e.g. /static/terms
Wildcards: A * can be used to match dynamic paths, e.g. /books/* can matches the path to any author’s page. ? inside specific path components, e.g. books/1? can be used to match any books whose ID starts with 1.
Exclusions: Prepending a path with NOT excludes that path from being matched.

数组中提到路径的顺序非常重要。早期指数具有更高的优先级。路径匹配后,评估将停止,其他路径将被忽略。每个路径都区分大小写。

The order in which the paths are mentioned in the array is important. Earlier indices have higher priority. Once a path matches, the evaluation stops, and other paths ignored. Each path is case-sensitive.

应用程序支持的每个域都需要提供它自己的apple-app-site-association文件。如果每个域提供的内容不同,则文件的内容也将更改为支持相应的路径。否则,可以使用相同的文件,但需要在每个支持的域中访问它。

Each domain supported in the app needs to make available its own apple-app-site-association file. If the content served by each domain is different, then the contents of the file will also change to support the respective paths. Otherwise, the same file can be used, but it needs to be accessible at every supported domain.

使用Apple App搜索验证工具验证您的服务器

测试iOS 9搜索API的网页。输入网址,Applebot会抓取您的网页,并展示如何优化以获得最佳效果
https://search.developer.apple.com/appsearch-validation-tool/

网站代码可以在
上找到gh-pages分支 https://github.com/vineetchoudhary/iOS-Universal-Links/tree/gh-pages

注意如果您的服务器使用 HTTPS 来提供内容并跳转到应用程序设置指南,则可以跳过此部分。

Note: You can skip this part if your server uses HTTPS to serve content and jump to Application Setup guide.

如果您的应用针对iOS 9而您的服务器使用 HTTPS 来提供内容,则无需对该文件进行签名。如果不是(例如,在iOS 8上支持Handoff时),则必须使用来自认可的证书颁发机构的 SSL 证书进行签名。

If your app targets iOS 9 and your server uses HTTPS to serve content, you don’t need to sign the file. If not (e.g. when supporting Handoff on iOS 8), it has to be signed using a SSL certificate from a recognized certificate authority.

注意:这不是Apple提供的将应用程序提交到App Store的证书。它应该由第三方提供,并且建议使用您用于 HTTPS 服务器的相同证书(尽管不是必需的)。

Note: This is not the certificate provided by Apple to submit your app to the App Store. It should be provided by a third-party, and it’s recommended to use the same certificate you use for your HTTPS server (although it’s not required).

要对文件进行签名,请先创建并保存一个简单的.txt版本。接下来,在终端中,运行以下命令:

To sign the file, first create and save a simple .txt version of it. Next, in the terminal, run the following command:

cat <unsigned_file>.txt | openssl smime -sign -inkey example.com.key -signer example.com.pem -certfile intermediate.pem -noattr -nodetach -outform DER > apple-app-site-association

这将在当前目录中输出签名文件。 example.com.key example.com.pem intermediate.pem 是您的认证机构可以使用的文件。

This will output the signed file in the current directory. The example.com.key, example.com.pem, and intermediate.pem are the files that would made available to you by your Certifying Authority.

注意:如果文件未签名,它应该有一个 Content-Type application / json 。否则,它应该是 application / pkcs7-mime

Note: If the file is unsigned, it should have a Content-Type of application/json. Otherwise, it should be application/pkcs7-mime.

如何在iOS App和设置服务器中支持Universal Links?

这篇关于如何在服务器上为iOS应用程序上传文件apple-app-site-association以进行通用链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆