【问题标题】:apple-app-site-association JSON not showing up?apple-app-site-association JSON 没有出现?
【发布时间】:2021-06-29 18:52:05
【问题描述】:

我已经实现了我的关联like it is done here,但是当我通过以下方式检查 JSON 时:https://day21.co/apple-app-site-association

​ 这显示了:

{"applinks":{"apps":[],"details":[]}}

而不是我在文件中的内容: ​

    {
    "applinks": {
        "apps": [],
        "details": [
        {
            "appID": "BID.com.Name.SignUpFlowclub"
            "paths": ["*"]
        }
        ]
    }
}

在这里您可以看到文件的位置,我将其 Firebase 部署到托管成功。 https://i.stack.imgur.com/tX5K2.png

我做错了什么?

【问题讨论】:

    标签: ios xcode apple-app-site-associate apple-app-site-association


    【解决方案1】:

    您正在尝试读取 .txt 文件。

    只需将该扩展名更改为 .json 并再次阅读。

    然后像下面这样读取 json。

    func readJson() {
            let jsonUrl = Bundle.main.url(forResource: "apple-app-site-association", withExtension: "json")!
            do {
                let data = try Data(contentsOf: jsonUrl, options: .mappedIfSafe)
                let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
                let result = jsonResult as! [String : Any]
            } catch let error {
                print(error)
            }
        }
    

    【讨论】:

    • 好吧,当您使用 Apple-app-site-association 时,您似乎不应该使用任何扩展... json 或 txt... 我假设计算机默认将其自动标记为 txt但实际上不是 txt,因为它没有扩展名(文件)
    • 好的。可以告诉我你在哪里生成 apple-app-site-association 的代码,所以我可以帮助你。
    • 是的,我相信这是我的问题...我通过在 teriamnal 中执行 $ touch apple-app-site-association 生成了 apple-app-site-association
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-28
    • 2017-02-16
    • 1970-01-01
    • 1970-01-01
    • 2016-01-06
    • 2021-09-13
    • 2016-03-13
    相关资源
    最近更新 更多