0

I am setting up my apple-app-site-association file follow this tutorial: Handoff works on iOS 8 but handoff does not work on iOS 9. I setup a free hosting site and upload the apple-app-site-association file onto the root of website: universallink.net46.net 1. I created a JSON file and named it handoff.json:

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

The XXXXXXXXXX here is the team id of the Distribution provisioning profile

  1. I used Keychain Access app to export a iPhone Distribution certificate to a Certificates.p12 key.
  2. I signed the JSON file with these commands:

Create a certificate in the openssl command.

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

Create a secret key.

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

Create an intermediate certificate.

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

Sign the handoff.json file with the following command.

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. I uploaded the signed file "apple-app-site-association" onto the root of website universallink
  2. I configured the entitlement:
<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. I implement the function application:continueActivity.... and return YES.
  2. I installed the app on the iOS 9 beta 4 device and also installed the Certificates.p12 at step 3 into the device.
  3. I sent a message to myself the link of universallink website
  4. I expected my app would be launched but actually, it was Safari.

I don't know if I did something wrong.

  • I believe you cannot sign the son file with a self signed cert. It has to be a valid and known SSL certificate recognized by Apple: https://support.apple.com/en-us/HT204132 – valheru Aug 05 '15 at 13:56
  • oh I see you're actually using your apple distribution cert. I wonder if that should work or not. – valheru Aug 05 '15 at 14:36
  • I am unable to get this to work myself either but I'm using actual paths so I'd say try adding some actual paths instead of just * ? Something to try anyway. – valheru Aug 05 '15 at 15:00
  • Well I finally got this working but it was signed with a valid CA and intermediate cert. When I did it with my iOS cert it did not work though =/ – valheru Aug 10 '15 at 17:47
  • Thank you for your response. How about unsigned JSON? – thanhhieu2710 Aug 12 '15 at 02:26
  • have not tried just the unsigned json but I assume that'd not work considering the whole point of it was to have it signed. – valheru Aug 12 '15 at 14:38
  • This is you get this to work? If yes, what was the problem? – rocir Aug 12 '15 at 21:30
  • Currently, I don't have a valid CA and intermediate certificate to sign it. So I try to upload an unsigned JSON to server, but it does not work also. There's a guy in Apple Developer forum said that he succeeded with the unsigned JSON, so I am looking forward to his unsigned JSON to see if there is anything wrong with the my JSON file format. – thanhhieu2710 Aug 16 '15 at 04:01
  • (WWDC also said that unsigned JSON work from seed 2 of iOS 9) – thanhhieu2710 Aug 16 '15 at 04:08
  • After seeing the device log, I found out that the first launch of the app will download apple-app-site-association JSON file from HTTPS domain, not HTTP. So that is the problem. I am using GitHub pages for testing with HTTPS domain. But the next problem I am facing is that iOS does not download the JSON file from GitHub page without "www" prefix (GitHub only provide https:// hieuth.github.io/ not www. hieuth.github.io/) – thanhhieu2710 Aug 18 '15 at 06:58
  • @thanhhieu2710 did you found the solution? – Ravindhiran Sep 07 '15 at 11:15
  • Hi Ravindhiran, Currently I don't have any SSL server to upload the JSON, so I can't go on. – thanhhieu2710 Sep 08 '15 at 10:28
  • @thanhhieu2710 But i have ssl certificates like server.key,server.crt and bundle.crt how to convert into "apple-app-site-association" – Ravindhiran Sep 08 '15 at 11:17

3 Answers3

2

You are signing it wrong. You need a

certificate and key for an identity issued by a certificate authority trusted by iOS

See apples official documentation here: https://developer.apple.com/library/prerelease/ios/documentation/UserExperience/Conceptual/Handoff/AdoptingHandoff/AdoptingHandoff.html#//apple_ref/doc/uid/TP40014338-CH2-SW10

der_michael
  • 3,151
  • 1
  • 24
  • 43
  • Currently, I don't have a valid CA and intermediate certificate to sign it. So I try to upload an unsigned JSON to server, but it does not work also. There's a guy in Apple Developer forum said that he succeeded with the unsigned JSON (WWDC also said that unsigned JSON work from seed 2 of iOS 9), so I am looking forward to his unsigned JSON to see if there is anything wrong with the my JSON file format. – thanhhieu2710 Aug 16 '15 at 04:08
  • @thanhhieu2710 But i have ssl certificates like server.key,server.crt and bundle.crt how to convert into "apple-app-site-association" – Ravindhiran Sep 08 '15 at 11:28
  • Hi Ravindhiran, you can try this instruction https://developer.apple.com/library/prerelease/ios/documentation/Security/Reference/SharedWebCredentialsRef/index.html#//apple_ref/doc/uid/TP40014989 – thanhhieu2710 Sep 08 '15 at 12:04
1

I Think This:

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

Should be this:

   "details": [{
        "appID": "XXXXXXXXXX.com.home.handoff",
        "paths": ["*"]
     }]
Craig
  • 11
  • 1
0

I was trying to make it work by using a local server (an OTA https python server) with a self created certificate using SSL and it didn´t work. I could track the communications and listen to the channel but in the different tests I tried, the json file was never asked for, so there is the problem, the SSL certificate. Go to : https://support.apple.com/en-gb/HT205205 as "not all the root certificates" are supported by apple (most of them are though).

AlfuryDB
  • 289
  • 1
  • 4