A.R*_*Roe 12 ios firebase reactjs applinks ios-universal-links
我试图在访问www.example.com/success时将用户重定向到已安装的应用程序,并在访问主页www.example.com时显示横幅。
\n在我当前的植入中,网址不会重定向并打开应用程序,网站也不会显示横幅。
\n我正在关注此处找到的文档https://developer.apple.com/documentation/safariservices/supporting_linked_domains
\n我的网站很简单create-react-app,主页由 Firebase 托管。
我做了以下事情:
\napple-app-site-association将文件添加到/public/我用什么来验证:
\nhttps://branch.io/resources/aasa-validator/
\nhttps://search.developer.apple.com/appsearch-validation-tool
\n通过将www.example.com/success链接添加到注释并打开进行测试,它总是在 safari 中打开。我还尝试过重新安装应用程序并重新启动手机。
\n苹果API验证
\n我已将带有关联域的新应用程序版本上传到商店
\n\nBranch.io
\n{\n "applinks": {\n "apps": [],\n "details": []\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n访问www.example.com/apple-app-site-association时
\n\n\n{ "activitycontinuation": { "apps": [ "team.com.example.com" ] },\n"applinks": { "apps": [], "details": [ { "appID":\n" team.com.example.com", "paths": [ "/", "/ ", "/success", "/success/ ",] }, "webcredentials": { "apps": [\n"team .com.example.com"] } }
\n
苹果应用程序站点关联
\n{\n "activitycontinuation": {\n "apps": [\n "team.com.example.com"\n ]\n },\n "applinks": {\n "apps": [],\n "details": [\n {\n "appID": "team.com.example.com",\n "paths": [\n "/",\n "/*", \n "/success",\n "/success/*", \n ]\n },\n ]\n },\n "webcredentials": {\n "apps": [\n "team.com.example.com"\n ]\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n索引.html
\n<link rel="apple-app-site-association file" href="%PUBLIC_URL%/apple-app-site-association">\n<link rel="apple-app-site-association file" href="/apple-app-site-association">\n<meta name="App" content="app-id=XXX, app-argument=https://apps.apple.com/US/app/APP/idXXX, affiliate- data=optionalAffiliateData">\nRun Code Online (Sandbox Code Playgroud)\nFirebase.json
\n{\n "hosting": {\n "public": "public",\n "headers": [\n {\n "source": "/apple-app-site-association",\n "headers": [\n {\n "key": "Content-Type",\n "value": "application/json"\n }\n ]\n }\n ],\n "appAssociation": "NONE"\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n设备控制台
\n安装应用程序时,我监视 Xcode 中的设备控制台,查看swdc进程日志以查找与关联域或请求相关的任何内容。这是我发现的一些;
\n\n获取企业管理的关联域数据时出错。如果此\n设备不是企业管理的,则这是正常的:错误\nDomain=SWCErrorDomain Code=1701“无法从 ManagedConfiguration 框架获取关联的域数据\n。”\nUserInfo={NSDebugDescription=无法从 ManagedConfiguration 获取关联的域数据\n框架。,行=298,功能=}
\n
\n\n条目 { s = applinks, a = , d = au\xe2\x80\xa6.ub\xe2\x80\xa6.com, ua = unspecified,\nsa =roved } 需要更新其 JSON,因为应用程序 PI 已更改
\n
https://developer.apple.com/library/archive/qa/qa1916/_index.html
\nRil*_*Dev 13
首先,在您的设备日志和 JSON 格式中,您似乎应该遵循此处显示的示例:https ://developer.apple.com/documentation/safariservices/supporting_linked_domains
在您的日志中,它可能会显示来自其他也具有过时 API 格式的应用程序的日志。然而,这不应该是一个大问题。
{
"applinks": {
"details": [
{
"appIDs": [ "ABCDE12345.com.example.app", "ABCDE12345.com.example.app2" ],
"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"
},
{
"/": "/buy/*",
"comment": "Matches any URL whose path starts with /buy/"
},
{
"/": "/help/website/*",
"exclude": true,
"comment": "Matches any URL whose path starts with /help/website/ and instructs the system not to open it as a universal link"
},
{
"/": "/help/*",
"?": { "articleNumber": "????" },
"comment": "Matches any URL whose path starts with /help/ and which has a query item with name 'articleNumber' and a value of exactly 4 characters"
}
]
}
]
},
"webcredentials": {
"apps": [ "ABCDE12345.com.example.app" ]
},
"appclips": {
"apps": ["ABCED12345.com.example.MyApp.Clip"]
}
}
Run Code Online (Sandbox Code Playgroud)
其次,按照Apple的故障排除和您的问题中的步骤,我猜您的问题可能是第7步
您的应用程序从以下 UIApplicationDelegate 协议方法之一返回 false:application( :continueUserActivity:restorationHandler:)、application( :willFinishLaunchingWithOptions:)、application(_:didFInishLaunchingWithOptions:)。
如果您解析了传递到这些方法中的 URL,并且您实现了逻辑来确定您的应用程序无法使用此 URL,则可能会发生这种情况。
您还没有发布您如何处理该 URL。您需要UIUserActivityRestoring按照其他答案中建议的方法来实现它才能发挥作用。这是 SwiftUI 版本
ContentView()
.onContinueUserActivity(NSUserActivityTypeBrowsingWeb) { userActivity in
print("Continue activity \(userActivity)")
guard let url = userActivity.webpageURL else {
return
}
print("User wants to open URL: \(url)")
// TODO same handling as done in onOpenURL()
}
Run Code Online (Sandbox Code Playgroud)
还添加
.onOpenURL { url in
print("URL OPENED")
print(url) // parse the url to get someAction to determine what the app needs do
if url.relativeString == "example://success" {
}
}
Run Code Online (Sandbox Code Playgroud)
https://developer.apple.com/library/archive/qa/qa1916/_index.html
中需要有一个appID apple-app-site-association:
{\n "applinks": {\n "apps": [],\n "details": [\n {\n "appID": "XXXXXXXXXX.com.example.UniveralLinks",\n "paths": ["*"]\n }\n ]\n }\n}\nRun Code Online (Sandbox Code Playgroud)\napplinks 标签确定哪些应用程序与网站关联。将 apps 值保留为空数组。详细信息标签内部是一个字典数组,用于链接 appID 和 URL 路径。为简单起见,您使用 * 通配符将此网站\xe2\x80\x99s 的所有链接与 UniversalLinks 应用程序关联起来。您可以将路径值限制为特定文件夹或文件名。\nappID 由您的团队 ID 与 app\xe2\x80\x99s 捆绑包 ID 组合而成,但您\xe2\x80\x99 需要使用您自己的标识符帐户。\n当您创建 Apple 开发者帐户时,Apple 为您分配了一个团队 ID。您可以在 Apple 开发者中心找到它。登录网站,单击“会员资格”,然后在“会员信息”部分中查找“团队 ID”。
\n现在您已拥有 apple-app-site-association,必须将其上传到 Web 服务器。\n您必须具有对该网站的\xe2\x80\x9c 写入权限\xe2\x80\x9d才能执行此操作。确保正确设置apple-app-site-association文件(在根目录或.well-known/Web 服务器上,并且没有重定向)。
您还必须添加适当的权利以通用链接到 iOS 应用。\n如果您使用的是 Xcode:
\napplinks:www.mywebsite.in然后您可以在“功能 -> 关联域”下添加例如。
或者在您的权利文件中,您可以添加如下内容:
\n<key>com.apple.developer.associated-domains</key>\n<array> \n ...\n <string>applinks:www.mywebsite.in</string>\n ...\n</array>\nRun Code Online (Sandbox Code Playgroud)\n处理通用链接:\n现在应用程序和网站已正式相互了解,应用程序所需的只是在调用\xe2\x80\x99 时处理链接的代码。
\nfunc application(\n _ application: UIApplication,\n continue userActivity: NSUserActivity,\n restorationHandler: @escaping ([UIUserActivityRestoring]?\n) -> Void) -> Bool {\n \n // 1\n guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,\n let url = userActivity.webpageURL,\n let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else {\n return false\n }\n \n // 2 // dig out component for deepLinking reference. \n if let component = ItemHandler.sharedInstance.items\n .filter({ $0.path == components.path}).first {\n //handle navigation to page indicated by component\n return true\n }\n \n // 3\n if let webpageUrl = URL(string: "http://universal-links-final.example.com") {\n application.open(webpageUrl)\n return false\n }\n \n return false\n}\nRun Code Online (Sandbox Code Playgroud)\n每当用户点击与应用程序相关的通用链接时,iOS 都会调用此方法。\xe2\x80\x99 是每个步骤的作用:\n首先,验证传入的 userActivity 是否具有预期的特征。最终,您想要获取活动的路径组件。否则,您返回 false 来指示应用程序可以\xe2\x80\x99t 处理该活动。\n使用该路径,您可以查找与其匹配的已知视图控制器。如果找到,则显示它的视图控制器并返回 true。\n如果\xe2\x80\x99t 找不到与该路径匹配的视图控制器,则指示应用程序打开该 URL,这将使用默认系统应用程序而不是 \xe2\x80\x94 最有可能是 Safari。您还可以在此处返回 false 以指示应用程序可以\xe2\x80\x99t 处理此用户活动。
\n| 归档时间: |
|
| 查看次数: |
25606 次 |
| 最近记录: |