【问题标题】:Handoff and Universal Links failed on iOS 9iOS 9 上的 Handoff 和 Universal Links 失败
【发布时间】:2015-07-24 07:19:28
【问题描述】:

我正在按照this 教程设置我的apple-app-site-association 文件: Handoff 适用于 iOS 8,但 Handoff 不适用于 iOS 9。 我设置了一个免费的托管站点并将 apple-app-site-association 文件上传到网站的根目录:universallink.net46.net 1.我创建了一个JSON文件并命名为handoff.json:

{
    "activitycontinuation": 
    {
        "apps": ["XXXXXXXXXX.com.home.handoff"]
    }, 
    "applinks":
    {
        "apps":[],
        "details":
        {
            "XXXXXXXXXX.com.home.handoff":
            {
                "paths":["*"]
            }
        }
    }
}

这里的 XXXXXXXXXX 是分发配置文件的团队 ID

  1. 我使用 Keychain Access 应用程序将 iPhone 分发证书导出到 Certificates.p12 密钥。
  2. 我使用以下命令对 JSON 文件进行了签名:

在 openssl 命令中创建证书。

openssl pkcs12 -in Certificates.p12 -clcerts -nokeys -out output_crt.pem

创建一个密钥。

openssl pkcs12 -in Certificates.p12 -nocerts -nodes -out output_key.pem

创建中间证书。

openssl pkcs12 -in Certificates.p12 -cacerts -nokeys -out sample.ca-bundle

使用以下命令签署 handoff.json 文件。

cat handoff.json | openssl smime -sign -inkey output_key.pem -signer output_crt.pem -certfile sample.ca-bundle -noattr -nodetach -outform DER> apple-app-site-association
  1. 我将签名文件“apple-app-site-association”上传到网站universallink的根目录
  2. 我配置了权利:
<dict>
  <key>com.apple.developer.associated-domains</key>
  <array>
      <string>activitycontinuation:www.universallink.net46.net</string>
      <string>activitycontinuation:universallink.net46.net</string>
      <string>applinks:www.universallink.net46.net</string>
      <string>applinks:universallink.net46.net</string>
  </array>
</dict>
  1. 我实现了函数 application:continueActivity.... 并返回 YES。
  2. 我在 iOS 9 beta 4 设备上安装了该应用,并且还在设备中安装了第 3 步中的 Certificates.p12。
  3. 我给自己发了一条universallink网站的链接
  4. 我预计我的应用会启动,但实际上是 Safari。

不知道是不是我做错了。

【问题讨论】:

  • 我相信您无法使用自签名证书签署子文件。它必须是 Apple 认可的有效且已知的 SSL 证书:support.apple.com/en-us/HT204132
  • 哦,我看到您实际上正在使用您的苹果发行证书。我想知道这是否应该工作。
  • 我自己也无法让它工作,但我使用的是实际路径,所以我想说尝试添加一些实际路径而不仅仅是 * ?无论如何都要尝试一下。
  • 好吧,我终于得到了这个工作,但它是用有效的 CA 和中间证书签名的。当我使用我的 iOS 证书进行操作时,它并没有起作用 =/
  • 感谢您的回复。未签名的 JSON 怎么样?

标签: ios ios9 handoff


【解决方案1】:

你签错了。你需要一个

由 iOS 信任的证书颁发机构颁发的身份证书和密钥

在此处查看苹果官方文档:https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/Handoff/AdoptingHandoff/AdoptingHandoff.html#//apple_ref/doc/uid/TP40014338-CH2-SW10

【讨论】:

  • 目前,我没有有效的 CA 和中间证书来签署它。所以我尝试将未签名的 JSON 上传到服务器,但它也不起作用。苹果开发者论坛里有个家伙说他用未签名的 JSON 成功了(WWDC 也说未签名的 JSON 从 iOS 9 的种子 2 开始工作),所以我很期待他的未签名的 JSON,看看我的JSON 文件格式。
  • @thanhhieu2710 但我有 ssl 证书,如 server.key、server.crt 和 bundle.crt 如何转换为“apple-app-site-association”
  • 嗨 Ravindhiran,你可以试试这个指令developer.apple.com/library/prerelease/ios/documentation/…
【解决方案2】:

我认为:

 "details":
        {
            "XXXXXXXXXX.com.home.handoff":
            {
                "paths":["*"]
            }
        }

应该是这样的:

   "details": [{
        "appID": "XXXXXXXXXX.com.home.handoff",
        "paths": ["*"]
     }]

【讨论】:

    【解决方案3】:

    我试图通过使用本地服务器(OTA https python 服务器)和使用 SSL 的自创证书使其工作,但它没有工作。我可以跟踪通信并收听频道,但在我尝试的不同测试中,从未要求过 json 文件,因此存在 SSL 证书的问题。 转到:https://support.apple.com/en-gb/HT205205,因为苹果支持“并非所有根证书”(但大多数都支持)。

    【讨论】:

      最近更新 更多