I'm trying to handle clicks on "tel:xxxxx" links in WKWebView. The code below works on iPhone, but on an iPad the callback webView(_ webView:,decidePolicyFor:,decisionHandler:) is not called. Is there any workaround?
import UIKit
import WebKit
class ViewController: UIViewController, WKNavigationDelegate {
@IBOutlet weak var webView: WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
webView.navigationDelegate = self
webView.loadHTMLString("<html><body><a href=\"tel:4085551212\">Click here to call</a></body></html>", baseURL: nil)
}
// MARK: - WKNavigationDelegate
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
if let url = navigationAction.request.url {
print("navigation to url: \(url)")
}
decisionHandler(.allow)
}
}