mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2025-02-03 20:37:34 +01:00
Adds handling of tel
url schemes
This commit is contained in:
parent
f901436211
commit
e825a5d516
@ -14,4 +14,9 @@ extension URL {
|
|||||||
var emailAddress: String? {
|
var emailAddress: String? {
|
||||||
scheme == "mailto" ? URLComponents(url: self, resolvingAgainstBaseURL: false)?.path : nil
|
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" {
|
} else if components?.scheme == "mailto" {
|
||||||
decisionHandler(.cancel)
|
decisionHandler(.cancel)
|
||||||
|
|
||||||
guard let emailAddress = components?.url?.emailAddress else {
|
guard let emailAddress = url.emailAddress else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,6 +328,13 @@ extension WebViewController: WKNavigationDelegate {
|
|||||||
alert.addAction(.init(title: "Dismiss", style: .cancel, handler: nil))
|
alert.addAction(.init(title: "Dismiss", style: .cancel, handler: nil))
|
||||||
self.present(alert, animated: true, completion: 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 {
|
} else {
|
||||||
decisionHandler(.allow)
|
decisionHandler(.allow)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user