【发布时间】:2025-12-16 18:30:01
【问题描述】:
我有下面的源代码。
当 URL 方案有 tel、sms、item- 或 mailto 时,WkWebview 将打开应用程序。 (item 和 mailto 是我们的自定义方案)
我想知道使用decisionHandler(.cancle)和decisionHandler(.allow)有什么区别,因为在这两种情况下实现UIApplication.shared.open(URL)是一样的。
if scheme == "tel" || scheme == "sms" || scheme == "itms-services" {
UIApplication.shared.open(destinationUrl)
decisionHandler(.allow)
return
}
else if scheme == "mailto" {
UIApplication.shared.open(URL(string: "ncsone://mail/write"))
decisionHandler(.cancel)
return
}
【问题讨论】: