I have a backend hosted on Azure AppService (linux) which is a SpringBoot 3 Application.
I put an apple-app-site-association.json
file to /static/ and added a WebMvcConfigurer like that:
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
// web in jar
registry.addResourceHandler("/**")
.addResourceLocations("classpath:/static/")
.resourceChain(true)
.addResolver(object : PathResourceResolver() {
@Throws(IOException::class)
override fun getResource(resourcePath: String, location: Resource): Resource? {
val requestedResource = location.createRelative(resourcePath)
return if (requestedResource.exists() && requestedResource.isReadable) {
requestedResource
}
// env dependent file for ios universal deeplinks
else if (resourcePath == "apple-app-site-association") {
ClassPathResource("/static/apple-app-site-association-${environment.activeProfiles.first()}.json")
}
else {
ClassPathResource("/static/web/index.html")
}
}
})
}
I often read that .json should not be included in the filename, however I have some trouble setting the content-type with this resourcehandler and I am not sure if it is also necessary when it is done like this since the https://branch.io/resources/aasa-validator/ validates the domain.
The app gets the error Error getting enterprise-managed associated domains data
in the device console when the app gets installed.
I realised that the problem was not the approach how the file is served but the file itself.
The teamId
was missing in the appId
field of the file:
{
"applinks": {
"details": [
{
"appIDs": [
"<teamId>.app.id.dev"
],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "Matches any URL whose fragment equals no_universal_links and instructs the system not to open it as a universal link"
},
{
"/": "/link/*",
"comment": "comment"
}
]
}
]
}
}