Adds handling of `tel` url schemes
This commit is contained in:
parent
f901436211
commit
e825a5d516
|
@ -14,4 +14,9 @@ extension URL {
|
|||
var emailAddress: String? {
|
||||
scheme == "mailto" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil
|
||||
}
|
||||
|
||||
/// Extracts telephone number from a `URL` with a `tel` scheme, otherwise `nil`.
|
||||
var telNumber: String? {
|
||||
scheme == "tel" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil
|
||||
}
|
||||
}
|
||||
|
|
|
@ -314,7 +314,7 @@ extension WebViewController: WKNavigationDelegate {
|
|||
} else if components?.scheme == "mailto" {
|
||||
decisionHandler(.cancel)
|
||||
|
||||
guard let emailAddress = components?.url?.emailAddress else {
|
||||
guard let emailAddress = url.emailAddress else {
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -328,6 +328,13 @@ extension WebViewController: WKNavigationDelegate {
|
|||
alert.addAction(.init(title: "Dismiss", style: .cancel, handler: nil))
|
||||
self.present(alert, animated: true, completion: nil)
|
||||
}
|
||||
} else if components?.scheme == "tel" {
|
||||
decisionHandler(.cancel)
|
||||
|
||||
if UIApplication.shared.canOpenURL(url) {
|
||||
UIApplication.shared.open(url, options: [.universalLinksOnly : false], completionHandler: nil)
|
||||
}
|
||||
|
||||
} else {
|
||||
decisionHandler(.allow)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue