I have uploaded my apple-app-site-association file to the root of my HTTPS web server After, I have added my Associated Domains in the xcode .I have followed apple universal link tutorial.
[SWC] ### Denying redirect to 'https://examplecustomdomain.com/apple-app-site-association/' (original 'https://examplecustomdomain.com/apple-app-site-association')
I have checked my device logs and I have seen error like above
I'm getting an awfully similar error:
[SWC] ### Denying redirect to 'https://www.<domain>/apple-app-site-association' (original 'https://<domain>/apple-app-site-association')
Quoting Apple's documentation:
The file must be hosted on an https:// site with a valid certificate (for example, Safari must not issue a certificate warning when viewing the site).
The file must not use any redirects.
The file must have the MIME type application/pkcs7-mime.
My guess here is that -for both of us,- the file can be obtained, but it is after being redirected. The OS won't follow that redirection even if it is under the same domain; And, apparently, complains about it on the log.
Run curl -i https://<domain>/apple-app-site-association
and you might see HTTP/1.1 301 Moved Permanently
, with Location: https://www.<domain>/apple-app-site-association
(or similar).
Ran into this same issue recently trying to implement Universal Links functionality. fbeeper gave a good response that helped me validate that there was indeed a redirect occurring.
However, it didn't help me in determining how to resolve the redirect issue. So for those like myself that are working with a Ruby on Rails based backend, here's an example of how to serve that pesky apple-app-site-association file in a way that meets all of Apple's requirements:
apple_app_site_association
json file in the public
folderconfig/routes.rb
file, add a line like:get '/apple-app-site-association' => 'home#apple_app_site_association'
Then in the relevant controller file (home_controller in this example), define your method:
def apple_app_site_association
association_json = File.read(Rails.public_path + "apple-app-site-association")
render :json => association_json, :content_type => "application/pkcs7-mime"
end
It works only on https server.
Steps:
1) Create a file like apple_app_site_association without any extension under public directory of rails application with following contents
{
"applinks": {
"apps": [],
"details": [
{
"appID": "<TEAM_DEVELOPER_ID>.<BUNDLE_IDENTIFIER>",
"paths": [ "*" ]
}
]
}
}
2) routes.rb
get '/apple-app-site-association', to: 'pages#apple_app_site_association'
3) pages_controller.rb
def apple_app_site_association
association_json = File.read(Rails.public_path + "apple_app_site_association")
render :json => association_json, :content_type => "application/json"
end
For example you check
http://18.216.158.101/apple-app-site-association
To test you can create an app on heroku.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With