Make Directory tel: and mailto: links and accessing location work in dapp browser

pull/1721/head
Hwee-Boon Yar 5 years ago
parent 241e87a26e
commit bbb990937a
  1. 16
      AlphaWallet/Browser/ViewControllers/BrowserViewController.swift
  2. 2
      AlphaWallet/Info.plist

@ -216,6 +216,22 @@ extension BrowserViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
handleError(error: error)
}
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> ()) {
guard let url = navigationAction.request.url, let scheme = url.scheme else {
return decisionHandler(.allow)
}
guard ["tel", "mailto"].contains(scheme) else {
return decisionHandler(.allow)
}
let app = UIApplication.shared
if app.canOpenURL(url) {
decisionHandler(.cancel)
app.open(url)
} else {
decisionHandler(.allow)
}
}
}
extension BrowserViewController: WKScriptMessageHandler {

@ -82,6 +82,8 @@
<string>$(ALPHAWALLET_PRODUCT_NAME) uses the camera to scan QR codes</string>
<key>NSFaceIDUsageDescription</key>
<string>Access your wallet</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Location data may be accessed when you are using the in-app browser and tap on a link to retrieve your current location</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>Sending QR Code to your contacts</string>
<key>NSPhotoLibraryUsageDescription</key>

Loading…
Cancel
Save