I'm using UIWebView in my application for some reasons that WKWebView can't fit for me.
Explaining that, I just finished with my application conversion to Swift3 (Was 2.2) and my shouldStartLoadWith
functions not getting the JS event.
If i run my previous build before the conversion - everything working perfect.
My code look like this:
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
let url:URL = request.url!
if (url.scheme == "something"){
if (url.host != nil){
var properString = url.absoluteString.removingPercentEncoding!
properString = properString.replacingOccurrences(of: "something://", with: "")
performJSFunction(message: properString)
}
return false;
}
return true
}
note: nothing changes in the server side/html page.
After many tries i have found out that the
UIWebView
will get events withhttps://
orhttp://
in the beginning.so if you used to get it like this:
now you should get it like this:
(pay attention that the dots after the "appname" will be remove automatically - even if you will send it via
src attribute
.i know it's not what you wanted to be - but it works really good.