I have a module inside my iOS 7+ app which is a UIWebView. The html page loads a javascript that creates custom-shaped buttons (using the Raphaeljs library). With UIWebView,
for swift 4.2: (taking from Yifei He 何一非. )
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: (WKNavigationActionPolicy) -> Void) {
let url = navigationAction.request.url
let urlStr = url?.absoluteString
switch urlStr {
case BASE_URL:
//self.someFunc()
decisionHandler(.cancel)
break
default:
decisionHandler(.allow)
break
}
}