ios - 在 AppDelegate 中访问 Universal Link app-argument
问题描述
我正在努力在我们的网站上实施通用链接,我遇到了一个看似简单但我无法弄清楚的问题。搜索 Google 和 Stack Overflow 没有帮助,这让我相信我可能只是遗漏了一些东西。
基本上,我将以下内容添加到我的页面标题(其 URL 为“https://www.website.com/slug”)。
<meta name="apple-itunes-app" content="app-id=xxx, app-argument=https://www.website.com/1" />
请注意,该app-argument
URL 与实际页面的 URL 不同。
我已经正确设置了我的 apple-app-site-association 文件。当我尝试在我们的 iOS 应用程序中处理通用链接时,我会这样做:
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
guard
userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL,
let components = URLComponents(url: url, resolvingAgainstBaseURL: true) else
{
return false
}
// Set breakpoint here.
return false
}
我在最后设置断点return false
,当我检查时components
,它包含实际页面 URL(“https://www.website.com/slug”)而不是通过传入的 URL app-argument
(“https://www.website .com/id”)。
所以我的问题是:如何app-argument
在我的 AppDelegate 中访问?
解决方案
推荐阅读
- java - 为什么将实体添加到集合中不会将它们添加到数据库中?
- sql - SQL server:当您只能访问月份和年份时计算年龄
- node.js - 从 Google Apps 脚本中的 https 调用获取状态文本
- session-cookies - SameSite=Strict cookie 保护在 Chrome 和 Firefox 中是否被破坏?
- python - 如何从用户获取文件路径然后传递给函数(argparse)
- c# - 两个数组合为一个字典 C#
- python - 在 Pandas 列中为数字添加字母
- php - 升级到 PHP 7.4 后无法识别的哈希算法
- vb.net - 和数字行 VB.Net
- java - com.sun.net.httpserver.HttpExchange 属性是否损坏?