WKURLSchemeHandler for http and https resource requests
Hi Wilddylan,
As you mentioned, if you target iOS 11, you can now use WKURLSchemeHandler to avoid this trick! 😆
Could you please assist me in how we can add WKURLSchemeHandler support to monitor HTTP/HTTPS resources instead of this private API? AFAIK WKURLSchemeHandler is for custom schemes.
Any sample code would be appreciated.
Thanks, Aruna
`` Hi ArunaYarra,
Currently you can't intercept https/http scheme request using WKURLSchemeHandler Since Apple will throw error while you try to register
let webConf = WKWebViewConfiguration() webConf.setURLSchemeHandler({{wkurlschemehandler instance}}, forURLScheme: "https")
//*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ''https' is a URL scheme that WKWebView handles natively'
however you intercept requests with custom scheme in you webview. like the below listed code. :
for HTML:
"///<html> ////<body> ///<img src = "customscheme://file/fileid"> ///</body> ///</html>
ios registeration code : let webConf = WKWebViewConfiguration() webConf.setURLSchemeHandler({{wkurlschemehandler instance}}, forURLScheme: "customscheme")
Thanks, Prabu