'Apple-app-site-association is not working
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.}
Solution 1:[1]
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.
Solution 2:[2]
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
Solution 3:[3]
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.
Solution 4:[4]
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | bradkratky |
| Solution 2 | Chase Finch |
| Solution 3 | Jaap Weijland |
| Solution 4 | Praveen G |


