10

I have implemented apple-app-site-association for deep linking with my iOS app.
I have created the .JSON file without extension and placed to my website's root directory.
Now, I can see the file as https://example.com/apple-app-site-association on any browser.

Following is the json body inside the apple-app-site-association file -

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

FYI I have added following inside my website's(angular.js) .htaccess -

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

I have already enabled the "Associated Domain" in both Xcode and developer.apple.com.
But, when I am trying to install a new build, its not working.
By digging into the device log, I am getting the following error.

Please take look and assist me about what I am doing wrong.

[SWC] ### Bad apple-app-site-association JSON: Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set." UserInfo={NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}

boraseoksoon
  • 2,164
  • 1
  • 20
  • 25
onCompletion
  • 6,500
  • 4
  • 28
  • 37
  • Hmm, This json code I got from developer.apple.com itself. So how is that possible..??..If you think so then please give me some corrected code if it is okay for you..!!! – onCompletion Oct 07 '16 at 14:17
  • @EricAya I just did that only. Copied from apple website and placed to an empty sublime text file and saved as apple-app-site-association file. Still don't understand why it is not working. Do you have any idea about how to debug the json for proper formatting..?? – onCompletion Oct 07 '16 at 14:21
  • @EricAya Now I followed your trick to. I have checked the json on `jsonlint.com` and it is showing as a valid JSON but getting the same issue. Pretty confused about what is going on..!! – onCompletion Oct 07 '16 at 14:26
  • Could we see the actual live file at its production location? FYI there is no confidential information in there — it is safe and not a security risk to share. – Alex Bauer Oct 07 '16 at 17:35

5 Answers5

11

Add .well-known/ to your path:

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

From https://developer.apple.com/documentation/safariservices/supporting_associated_domains_in_your_app

Chase Finch
  • 5,161
  • 1
  • 21
  • 20
10

The file is appropriately hosted, as confirmed by using:

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

You can also use Apple's Applebot to crawl your site to validate an apple-app-site-association. However, this only full verifies if your app is live.

The issue may not be with your association file. You should verify your app is indeed checking https://pravin-dev.slicepay.in/apple-app-site-association and not https://slicepay.in/apple-app-site-association. Double check your applinks in the Associated Domains section of your Capabilities, and the .entitlements file was properly generated. You are using the pravin-dev subdomain - if this was not specified your app may not be looking in the correct location.

As you may know you have to uninstall the app to re-check for the apple-app-site-association.

Ensure capabilities includes subdomain Ensure entitlements file was set properly

bradkratky
  • 1,577
  • 1
  • 14
  • 28
  • its as expected like yours but still getting the same issue. Remember, I am getting this error inside device log from iOS I guess. – onCompletion Oct 11 '16 at 04:32
  • 2
    I uninstall and reinstall the app but my newly added path in apple-app-site-association still doesn't work. Any ideas? – Hlung Aug 03 '17 at 11:02
9

The best way to test if your file is configured properly is to use

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

or

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

If you get the apple-app-site-association's JSON as a response your config is right, you can check your Associated Domains config. Uninstalling and Reinstalling helps, or try restarting your iPhone.

But if you didn't get JSON response from the above curl, the issue must be with server config

Praveen G
  • 794
  • 1
  • 13
  • 24
2

I had this also; the file was structured correctly, it was accessible both with and without .well-known, the entitlements were correct...

...it turns out that turning my device off and on fixed the issue. I think iOS will refetch universal links of apps upon restart or something.

If all else fails, try turning it off and on again.

Jaap Weijland
  • 3,146
  • 5
  • 23
  • 31
  • 2
    Dude, I wish I saw this a couple hours ago, could've saved me so much time trying to figure out what I did wrong. Hahah thanks! – Chan Jing Hong Jul 15 '21 at 15:02
-3

It appears that the file is somehow being served as the wrong type by the server. If you try to load a working AASA file in a web browser (https://branchmaps.app.link/apple-app-site-association), you'll see that it downloads immediately and the resulting file has no type. Your file is displaying in the browser, and comes out with a JSON file type when downloaded.

If you are saving the file as apple-app-site-association.json and then removing the extension, try instead saving it directly from Atom/Sublime/whatever without the filename to make sure the OS doesn't embed metadata.

You could also use a free deep link platform like Branch.io (full disclosure: I'm on the Branch team) and not need to handle this server configuration :)

Alex Bauer
  • 13,147
  • 1
  • 27
  • 44
  • I am creating the json file in sublime only with the extension and deploying to our server which is maintained using Apache 2 and front-end has been developed using Anguler. I am also using this code ForceType application/json inside .htaccess but no result. – onCompletion Oct 07 '16 at 18:19
  • @bradkratky yes I do. My apologies — I usually remember to put that disclosure in and somehow missed it here :(. Fixed now – Alex Bauer Oct 10 '16 at 20:54
  • @unexpectedNil I'm wondering if your `` expression is somehow mis-matching. What about trying with a simpler `` expression instead? ` ForceType application/json ` – Alex Bauer Oct 10 '16 at 21:01
  • @AlexBauer no worries, thanks. just got that sense from the answer! I think his json is set correctly, a curl yields the correct content-type for me – bradkratky Oct 11 '16 at 03:30
  • Guys thanks for your effort. I will try to do as you guys said and will let you know...:) – onCompletion Oct 11 '16 at 04:29
  • Interestingly when I look at a selection of known-good AASA files (Yelp, Pinterest, TripIt, etc) they either use content-type `text/plain` or `application/pkcs7-mime`. – Alex Bauer Oct 11 '16 at 15:56