Apple-app-site-association 不起作用

问题描述 投票:0回答:6

我已经实现了

apple-app-site-association
来与我的 iOS 应用程序进行深度链接。
我创建了不带扩展名的 .JSON 文件,并将其放置到我网站的根目录中。
现在,我可以在任何浏览器上看到该文件为 https://example.com/apple-app-site-association

以下是 apple-app-site-association 文件中的 json 正文 -

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "AppID.bundleIdentifier",
                "paths": [ "*"]
            }
        ]
    }
}

仅供参考,我在我的网站(angular.js).htaccess 中添加了以下内容 -

<FilesMatch "^apple-app-site-association$"> ForceType application/json </FilesMatch>

我已经在 Xcode 和developer.apple.com 中启用了“关联域”。
但是,当我尝试安装新版本时,它不起作用。
通过深入研究设备日志,我得到以下信息错误。

请查看并帮助我了解我做错了什么。

[SWC] ### 错误的 apple-app-site-association JSON:错误 Domain = NSCocoaErrorDomain Code = 3840“JSON文本不是以 数组或对象以及允许未设置片段的选项。” UserInfo={NSDebugDescription=JSON 文本未以数组开头或 允许未设置片段的对象和选项。}

swift ios9 ios-universal-links
6个回答
18
投票

测试文件配置是否正确的最佳方法是使用

curl -v https://app-site-association.cdn-apple.com/a/v1/yourdomain.com

curl -v https://app-site-association.cdn-apple.com/a/v1/sub.domain.com

如果您收到 apple-app-site-association 的 JSON 作为响应,您的配置是正确的,您可以检查您的关联域配置。卸载并重新安装会有所帮助,或者尝试重新启动您的 iPhone。

但是如果你没有从上面的curl中得到JSON响应,那么问题一定出在服务器配置上


12
投票

.well-known/
添加到您的路径中:

https://<fully qualified domain>/.well-known/apple-app-site-association

来自 https://developer.apple.com/documentation/safariservices/supporting_linked_domains_in_your_app


11
投票

文件已正确托管,通过使用确认:

curl -I https://pravin-dev.slicepay.in/apple-app-site-association

您还可以使用 Apple 的 Applebot 抓取您的网站以验证 apple-app-site-关联。但是,这只能完整验证您的应用程序是否已上线。

问题可能不在于您的关联文件。您应该验证您的应用程序确实正在检查 https://pravin-dev.slicepay.in/apple-app-site-association 而不是 https://slicepay.in/apple-app-site-association。仔细检查您的功能的关联域部分中的应用程序链接,并且 .entitlements 文件已正确生成。您正在使用 pravin-dev 子域 - 如果未指定,您的应用程序可能无法在正确的位置查找。

您可能知道,您必须卸载该应用程序才能重新检查 apple-app-site-association。

Ensure capabilities includes subdomain Ensure entitlements file was set properly


3
投票

我也有这个;文件结构正确,无论有没有 .well-known 都可以访问,权利是正确的...

...事实证明,关闭然后打开我的设备解决了问题。我认为 iOS 会在重新启动或其他情况下重新获取应用程序的通用链接。

如果其他方法都失败,请尝试将其关闭然后再次打开。


0
投票

我遇到了这个问题并终于找到了解决方案:

第1步:

在浏览器中打开链接 https://example.com/apple-app-site-association 并检查结果是否为 来了。

第2步:

转到网站:https://jsonformatter.curiousconcept.com并检查您的 链接https://example.com/apple-app-site-association

就我而言,问题在于字符类型。它必须是utf-8。因此,我在 PHP 中创建了一个 API,并返回了一个 utf-8 字符类型的 JSON 响应,一切就开始工作了。

您必须在 xcode 应用程序中执行步骤,例如注册关联域等。


-3
投票

服务器似乎以某种方式将文件提供为错误的类型。如果您尝试在网络浏览器中加载工作的 AASA 文件 (https://branchmaps.app.link/apple-app-site-association),您会看到它立即下载,并且生成的文件没有类型。您的文件正在浏览器中显示,下载后会显示 JSON 文件类型。

如果您将文件另存为

apple-app-site-association.json
,然后删除扩展名,请尝试直接从 Atom/Sublime/任何不带文件名的文件保存它,以确保操作系统不会嵌入元数据。

您还可以使用免费的深层链接平台,例如 Branch.io(完全披露:我在 Branch 团队中),并且不需要处理此服务器配置:)

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.