I am working on a cordova ios (6.1.0) project and i want to implement a native WKURLSchemeHandler to intercept the custom scheme handling to solve my cors problems.
In detail I want to do something like: https://medium.com/@kumarreddy_b/custom-scheme-handling-in-uiwebview-wkwebview-bbeb2f3f6cc1
Till iOS 11, we do not have any system APIs to intercept events from WKWebView.In iOS 11 we got a new API called WKURLSchemeHandler for WKWebView to make our life simpler.
It means that if you want to handle some request on your own, then just define the custom scheme and set it to the WKWebViewConfiguration.
My custom scheme is app://myapp but i need to implement a WKURLSchemeHandler and register it to WKWebViewConfiguration.
Is there any way to implement native ios code on cordova?
You don't need to implement the SchemeHandler, its already in cordova-ios. Just put this scheme in your config.xml:
(and you might need to also set the iosExtraFilesystems and iosPersistentFileLocations prefs)
and in your JS code get the actual URL from WkWebKit, like for e.g. cordova.file.DataDirectory :