【发布时间】:2019-09-16 18:15:48
【问题描述】:
我已将自定义 URL 方案添加到我的 Xcode 项目(我正在使用 SwiftUI)。
在我添加的 AppDelagate 文件中:
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
print(url.absoluteString)
print("work")
return true
}
当我在模拟器或物理设备中访问 Safari (sampleurlscheme://) 时,代码不会被执行(即日志不显示等),但它会将我带到应用程序。
有什么我遗漏的或者这可能是一个错误吗?
【问题讨论】:
-
看来这是在 SceneDelegate.swift 中处理的,其功能是:func
scene(_ scene: UIScene, openURLContexts URLContexts: Set<UIOpenURLContext>) -
我也遇到了这个问题。谢谢!
-
访问此处以获取更新的 iOS 13 及更高版本:stackoverflow.com/questions/47291172/custom-url-schemes/…