英文:
Apple app site association file on azure app service (Spring Boot + Angular WebApp)
问题
我有一个托管在Azure AppService(Linux)上的后端,它是一个SpringBoot 3应用程序。
我将apple-app-site-association.json
文件放在/static/目录下,并添加了一个类似于以下的WebMvcConfigurer:
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")
}
}
})
}
我经常读到.json文件不应包含在文件名中,但是我在设置这个资源处理程序的内容类型时遇到了一些问题,我不确定在这种情况下是否也需要这样做,因为https://branch.io/resources/aasa-validator/验证了域名。
当应用程序安装时,设备控制台中出现Error getting enterprise-managed associated domains data
错误。
英文:
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.
答案1
得分: 0
我意识到问题不在于文件的提供方式,而在于文件本身。
在文件的appId
字段中缺少了teamId
:
{
"applinks": {
"details": [
{
"appIDs": [
"
],
"components": [
{
"#": "no_universal_links",
"exclude": true,
"comment": "匹配任何片段等于no_universal_links的URL,并指示系统不将其作为通用链接打开"
},
{
"/": "/link/*",
"comment": "评论"
}
]
}
]
}
}
英文:
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"
}
]
}
]
}
}
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论