swift - apple-app-site-association 文件是否适用于 GitHub Pages(即 site.github.io)?

标签 swift passwords

我正在尝试为应用程序设置强密码支持。

我有一个包含正确项目的有效 JSON 文件:

{
"appLinks": {
    "apps": [],
    "details": [{}]
},
"webcredentials": {
    "apps": [ "<TEAMID>.<BUNDLEID>", "<TEAMID>.<BUNDLEID>" ]
}

}

我在 repo 中包含了一个“.nojekyll”文件以允许 .文件夹访问 .我已经用 ( https://branch.io/resources/aasa-validator ) 验证了这一点。

我已将文件放在 /.well-known/apple-app-site-association

我已将功能添加到我的应用程序并三次检查了我的 团队 ID 捆绑标识符 .

我也有从我的设备中删除了该应用程序并安装了并在连接和不连接调试器的情况下运行。

我开始想 GitHub 页面 由于某种原因不支持此功能。

注意:我的 bundleID 是明确的,意思是我使用的是“app”而不是“com.company.app”

我这样想对吗?

最佳答案

不,我无法单独使用 GitHub Pages。如果你不关心为什么你可以跳过下一点。
为什么仅 GitHub Pages 是不够的
据我所知,仅 GitHub Pages 不会在 .well-known/apple-app-site-association 上提供文件。与 Content-Type: application/json . Apple's validation tool不会通过。这个需要:

  • .well-known/apple-app-site-association待送达(您可以使用 curl -v mysite.com/.well-known/apple-app-site-association 进行测试)
  • 必须使用 Content-Type: application/json标题。
  • 不能有任何重定向;即必须在不添加 -L 的情况下工作给您的curl命令。

  • 这是我尝试仅使用全部失败的 GitHub 页面的解决方案:
  • 我首先想到的是添加 .nojekyll到 repo 的顶级目录,以便 .well-known/apple-app-site-association可以提供服务。尝试使用符号链接(symbolic link)重定向 apple-app-site-associationapple-app-site-association.json
  • 它仍然被用作Content-Type: octet-stream

  • 创建目录/文件结构.well-known/apple-app-site-association/index.json
  • 这未通过 Apple 验证,因为 mydomain.com/.well-known/apple-app-site-association重定向到 mydomain.com/.well-known/apple-app-site-association/在返回正确的内容和正确的内容类型 header 之前。


  • GH Pages 解决方案之上的 Cloudflare/CDN
    但是,我也在使用 Cloudflare to CDN the static pages my GitHub Pages site hosted .您可以在免费级别进行设置,如果您的页面获得任何真正的流量,可能应该这样做。您可能会选择另一个 CDN,但它需要某种支持 Apple 要求的内容类型/无重定向内容的自定义路由。在 Cloudflare 中,我可以通过他们的 Workers 的免费层免费实现这一点(除非我有大量的流量)。如果您在 GitHub Pages 站点上使用另一个 CDN,您可能可以将其余部分调整为您首选的 CDN。
    在 Cloudflare 的“Workers”页面中,单击“Manage Workers”,然后单击“Create Worker”。根据需要复制/粘贴以下 JSON(它包含您的 apple-app-site-association JSON):
    addEventListener('fetch', event => {
      event.respondWith(handleRequest(event.request))
    })
    
    /**
     * Respond to the request
     * @param {Request} request
     */
    async function handleRequest(request) {
      return new Response(JSON.stringify(
      // This is actually your JSON. Because this is JavaScript, you can also add in comments if you like.
    {
      "applinks": {
        "details": [
          {
             "appID": "Q94XRK95RT.io.beatscratch.beatscratchFlutterRedux",
             "paths": [ "/app/", "/app"]
          }
        ]
       }
    }) + "\n"
    , {
      headers: {
          "content-type": "application/json",
        },
      status: 200
      })
    }
    
    请注意,我必须使用 here 中的 JSON 结构。 .这让上面链接的验证器显示“错误没有与 url 关联的应用程序”,这听起来很糟糕......但一切正常。
    我将 Worker 命名为 apple-app-site-association但你可以随意命名它。然后您可以路由 my-site.com/.well-known/apple-app-site-association给 worker 。

    关于swift - apple-app-site-association 文件是否适用于 GitHub Pages(即 site.github.io)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60357663/

    相关文章:

    objective-c - 在 Swift 中实现 Objective c 协议(protocol)

    ios - SKScene 节点未检测到触摸

    git - 更改 NetBeans 使用的 Git 远程密码

    php - password_hash 中的默认算法是什么

    javascript - 轻量级 zxcvbn 替代方案?

    powershell - [System.Web.Security.Membership]::GeneratePassword() - 找不到类型

    swift - 遗留构造函数违规 : Swift constructors are preferred over legacy convenience functions. (legacy_constructor)

    ios - 使用 Swift 在 iOS 中将 CFAffineTransformRotation 应用于父 View 时禁用 subview 的自动旋转?

    json - 使用 ObjectMapper 和 Alamofire 时对象始终为零

    尽管设置了密码,MySQL 仍允许无密码连接