【发布时间】:2021-06-26 12:17:33
【问题描述】:
我试图在访问 www.example.com/success 时将用户重定向到已安装的应用程序,并在访问主页时显示横幅 www.example.com。
在我当前的植入中,网址不会重定向和打开应用程序,网站也不会显示横幅。
我正在关注此处的文档https://developer.apple.com/documentation/safariservices/supporting_associated_domains
我的网站是一个简单的create-react-app,其主页由 Firebase 托管。
我做了以下事情:
- 将关联域添加到签名和功能 - applinks:website.com/success
- 将
apple-app-site-association文件添加到/public/ - 修改firebase.json文件
- index.html 中文件的链接
我用来验证的内容:
https://branch.io/resources/aasa-validator/
https://search.developer.apple.com/appsearch-validation-tool
通过将www.example.com/success 链接添加到笔记并打开来进行测试,它始终在 safari 中打开。我也试过重新安装应用并重启手机。
Apple API 验证
我已将带有关联域的新应用版本上传到商店
Branch.io
{
"applinks": {
"apps": [],
"details": []
}
}
访问www.example.com/apple-app-site-association时
{ "activitycontinuation": { "apps": [ "team.com.example.com" ] }, “applinks”:{“apps”:[],“详细信息”:[{“appID”: "team.com.example.com", "paths": [ "/", "/", "/success", "/success/",] }, "webcredentials": { "应用”: [ “team.com.example.com”] } }
apple-app-site-association
{
"activitycontinuation": {
"apps": [
"team.com.example.com"
]
},
"applinks": {
"apps": [],
"details": [
{
"appID": "team.com.example.com",
"paths": [
"/",
"/*",
"/success",
"/success/*",
]
},
]
},
"webcredentials": {
"apps": [
"team.com.example.com"
]
}
}
Index.html
<link rel="apple-app-site-association file" href="%PUBLIC_URL%/apple-app-site-association">
<link rel="apple-app-site-association file" href="/apple-app-site-association">
<meta name="App" content="app-id=XXX, app-argument=https://apps.apple.com/US/app/APP/idXXX, affiliate- data=optionalAffiliateData">
Firebase.json
{
"hosting": {
"public": "public",
"headers": [
{
"source": "/apple-app-site-association",
"headers": [
{
"key": "Content-Type",
"value": "application/json"
}
]
}
],
"appAssociation": "NONE"
}
}
设备控制台
在安装应用程序时,我在 Xcode 中监视设备控制台,通过 swdc 进程日志查找与关联域或请求相关的任何内容。这是我找到的一些;
获取企业管理的关联域数据时出错。如果这 设备不是企业管理的,这是正常的:错误 Domain=SWCErrorDomain Code=1701 "获取关联域数据失败 来自 ManagedConfiguration 框架。” UserInfo={NSDebugDescription=获取关联域数据失败 ManagedConfiguration 框架。,Line=298,Function=}
Entry { s = applinks, a = , d = au....ub....com, ua = unspecified, sa = 已批准 } 需要更新其 JSON,因为应用 PI 已更改
https://developer.apple.com/library/archive/qa/qa1916/_index.html
【问题讨论】:
-
“我试图在访问 www.example.com/app 时将用户重定向到已安装的应用程序”...您的字面意思是 example.com 还是您只是避免发布您的真实域?因为您无法关联您不拥有的域(没有写入权限)...
-
@A.Roe,我理解正确吗?您想添加指向您网站的链接,然后如果用户将在具有现有本机应用程序的设备上并单击它,则本机应用程序会上升,如果不遵循网站路线。对吗?
-
@Alladinian 是的,我知道,我只是在隐藏我的域名
-
@AmerllicA 不,当用户打开例如 www.example.com/app 的 URL 时,会改为打开应用程序。如果他们访问 www.example.com,则应显示应用横幅。
-
@A.Roe,另一个问题,这个
www.example.com属于你吗?根据你的描述,我猜,你想通过子路由为/App的任何网站提高App。正确的?还是只是关于您自己的网站?
标签: ios reactjs firebase ios-universal-links applinks