I have my apple-app-site-association uploaded correctly on the server. It's formatted as follows:
{
"activitycontinuation": {
"apps": [
"ASDF.com.company.appname"
]
},
"applinks": {
"apps": [],
"details": [
{
"appID": "ASDF.com.company.appname",
"paths": [ "/menu/*", "/menu/*/*", "/account/history", "/"]
}
]
}
}
My entitlements is set up correctly:
applinks:company-site.com
activitycontinuation:company-site.com
I've verified with Charles proxy on install the device fetches the correct file from the server.
When looking at the device log, I get the following error:
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.}
I've ran the JSON through a linter and it came out fine. The server sends back Content-Type: application/json in the header. I'm testing on a physical device. I've tried typing the URLs manually in safari and clicking them through a text message. Does anyone see where the problem is?
I believe the first section of your apple-app-site-association is unnecessary and may be causing the validation error (Apple is pretty strict about this file). I haven't seen this in any other places — is there a particular reason you're including it?
Try this and see if it works better:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "ASDF.com.company.appname",
"paths": [ "/menu/*", "/menu/*/*", "/account/history", "/"]
}
]
}
}
Also note that Universal Links will never work when entered manually into Safari. See here for more info.
Related
We're trying to get universal links working in our app but we are encountering errors when trying to download the Apple App Site Association file.
We've used various online tools to validate the file and they all say their is a parsing error but they don't go into any detail about what the issue is.
We've validated that the JSON is valid but what else could be wrong with the file contents?
{
"applinks": {
"details": [
{
"appIDs": [ "12345NGB.co.uk.my.app" ],
"components": [
{
"/": "/universallink/*",
"comment": "Matches any URL whose path starts with /universallink/"
}
]
}
]
}
}
It turns the I did need to follow the format outlined here: https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html
{
"applinks": {
"apps": [],
"details": [{
"appID": "12345NGB.co.uk.my.app",
"paths": ["/universallink/*"]
}]
}
}
The Apple documentation is very misleading because it suggests that's an old format for supporting iOS 12 and earlier.
We've implemented Universal Links as described here so that users can confirm their account. We recently introduced some some new controllers/pages to our site and we found that all links will open the app regardless of what is in the apple-app-site-association file. I've checked our configurations and can't find an issue.
Before new pages added:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "XXXXXXXX.com.mybundle.identifier",
"paths": ["*"]
}
]
}
}
After new pages added:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "XXXXXXXX.com.mybundle.identifier",
"paths": ["NOT /about/*", "NOT /home/*", "*"]
}
]
}
}
Things to note:
I've tried several variations in the paths including "NOT /about*" or "NOT *" and all links will still open the app.
AASA Validator returns all green.
I've versioned and uninstalled between each test.
Any thoughts on what we could check next?
In the last section of document about allowing_apps_and_websites_to_link_to_your_content, it says:
Use wildcards in path strings within the paths array to specify
sections of your website. For example, append * to a specific URL,
such as /videos/samples/2015/, to specify all paths below
/videos/samples/2015/. Use ? to match any single character, such as
/photography//samples/201?/mypage. Use a standalone * to specify your
entire website.
And
Identify an area that should not be handled by adding “NOT ”
(including a space after the T) to the beginning of the path string.
So, in you second paths, you use NOT and * at the same time which is contradictory. I think you should change it to:
"paths": ["NOT /about/*", "NOT /home/*"]
Or something like
"paths": ["NOT /about/*", "NOT /home/*", "/vailddomain/*"]
I have not test it but I think it's probably the right solution.
I have apple-app-site-association file in my server root directory, so getting banner on my iOS safari browser, but when I remove the file from server, cleared my browser history, then reset my phone too, but still getting the banner.
Note : changed my app ID in the file, but not reflects in banner.
https://example.com/apple-app-site-association
apple-app-site-association file :
{
"applinks": {
"apps": [],
"details": [
{
"appID": "123456789.com.abc.example",
"paths": [ "*" ]
}
]
}
}
Your are getting the banner still because you haven't build the app again.
During the build process of the ios app it downloads the apple-app-association-file from the asociated domain and save it in the app for deeplinking purpose.
Once you get the new build with the updated apple-app-association-file
your problem will be solved.
To remove the banner from all the pages you can just try below code:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "your app id here",
"paths": [
"NOT /*"
]
}
]
} }
Here is my actual apple-app-site-association file:
{
"applinks": {
"apps": [],
"details": [ {
"appID": "XXXXXXXXX.com.example.app",
"paths": [
"NOT /Registration",
"/*"
]
}]
}
}
I would like to allow every urlendpoint to working as universal link, expect the example.com/Registration/whatever
But the above code not working. If I click on a registration link, it open my application.
I tried a lot of version of this file eg: "NOT /Registration/*", "NOT /Registration*", "NOT /Registration/", but no one work.
What is wrong?
UPDATE:
Here is my full example registration link:
https://example.com/Registration/AccountActivation?activationCode=XXXX
I do not have a fix for your problem, but I can give you a possible explanation. I'm leaving this here for reference in the hopes that I overlooked something.
Did you try reinstalling the app after changing the file? I had a simmilar problem not long ago. It seems that apple is only fetching the file once on install. From the orininal source:
During my troubleshooting, I discovered it’s best to verify an app is
making the HTTPS request for the apple-app-site-association file. It’s
important to know that apps only attempt to this once per
installation. The request occurs the first time an app is launched
after installation. Furthermore, force closing an app and then
launching it will NOT trigger the app to reload
apple-app-site-association.
via https://medium.com/#barsh/my-first-date-with-ios-universal-links-90dfabc88bb8#.wyrslx2di
As I said, there seems to be no solution on updating the file without a reinstall of the app.
NOT /Registration is a match for yourdomain.com/Registration but not any subpath e.g. /Registration/AccountActivation....
I believe this should achieve what you're looking for:
{
"applinks": {
"apps": [],
"details": [ {
"appID": "XXXXXXXXX.com.example.app",
"paths": [
"NOT /Registration/*",
"/*"
]
}]
}
}
I implemented Universal Links. The apple-app-site-association is structured as follows:
{
"applinks": {
"apps": [],
"details": [
{
"appID": "APPID.my.awesome.newspaper",
"paths": [ "NOT /webapp/issue/*/ads/*", "/webapp/issue/*/*.html" ]
}
]
}
}
For some reason the first path with the NOT is not considered at all.
For example:
These URL's are handled as expected:
awesome-newspaper.my/webapp/issue/sz/2016-01-22/page_2.157908/article_1.2828646/article.html
awesome-newspaper.my/webapp/issue/sz/2016-01-22/page_2.157908/page.html
This URL should not be handled as Universal Link and should always open in Safari.
awesome-newspaper.my/webapp/issue/sz/2016-01-22/ads/ad_145/index.html
But it always opens in the App as well.
Can someone please help me out?
i think the problem is that your URL matches both cases, which is then making the results unpredictable.
try making the paths mutually exclusive. if thats not possible you may need to change the URL structure.
UPDATE:
it's possible that your NOT string is ill formatted, try changing it to: "NOT /webapp/issue/*/ads/*/*.html"