【发布时间】:2020-01-14 12:26:53
【问题描述】:
我无法使动态链接或通用链接正常工作。我的应用程序不会读取 URL。我从一个新项目开始,将 com.company.AppLoginView 的 URL 方案和以下代码添加到 AppDelegate 中。我在注释中添加了一个 url:com.company.AppLoginView://Register?User=Name。单击链接请求打开应用程序,然后打开该应用程序。但是,似乎没有任何内容传递给应用程序,并且没有调用以下内容。我究竟做错了什么?这是一个完全空的应用程序,应该可以工作。
func application(_ app: UIApplication, open url: URL,
options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
if let scheme = url.scheme,
scheme.localizedCaseInsensitiveCompare("com.myApp") == .orderedSame,
let view = url.host {
var parameters: [String: String] = [:]
URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.forEach {
parameters[$0.name] = $0.value
}
print("View:\(view) Params:\(parameters) Scheme:\(scheme)")
// redirect(to: view, with: parameters)
}
return true
}
【问题讨论】:
标签: swift xcode appdelegate ios-universal-links