cordova-ios
cordova-ios copied to clipboard
API to access WKWebViewConfiguration
Feature Request - API to access WKWebViewConfiguration
Motivation Behind Feature
Our team is upgrading from Cordova 5 to 6 and migrating from UIWebView
to WKWebView
. Our app used to use NSURLProtocol
subclasses to handle certain requests from the UIWebView. This does not work with WKWebView
. The new approach is to use WKURLSchemeHandler
instances to handle requests made with a custom scheme. In order to do this, we need to register our scheme handlers with the WKWebViewConfiguration
for the WebView. Right now, there does not seem to be a way to do this with public API. We also need to set the websiteDataStore
on the WKWebViewConfiguration
in order to set cookies for the WebView.
Feature Description
One option: Make CDVWebViewEngine
a public class that class that can be extended. That way we can override createConfigurationFromSettings:
and access WKWebViewConfiguration
Also open to any other option that provides access to WKWebViewConfiguration
Alternatives or Workarounds
Our current workaround is to use a post_install
action in CocoaPods moves CDVWebViewEngine.h
and CDVWebViewUIDelegate.h
from private to public, then extending CDVWebViewEngine
CC: @lukemelia
That would be a very useful feature!
Any update on if/when this will gonna be supported?
Is there any progress in developing this feature?
Bump, exact same need
Any update on if/when this will gonna be supported?
Due to the volunteer nature of Apache projects, we can't really provide any timelines. AFAIK no one is looking into this feature, but with that being said, if there is a need for this feature (which there appears to be), anybody willing is free to develop and prepare a PR. A PR will likely be best way to discuss potential solutions since reviewers can see the actual code changes.
Additionally if you have any questions regarding developing this feature, you may ask our Slack Community or subscribe to our Dev Mailing List.
@breautek what about https://github.com/apache/cordova-ios/pull/1157
Looks like this might actually be resolved by https://github.com/apache/cordova-ios/pull/1050
Looks like this might actually be resolved by #1050
I haven't tried this myself yet, but looks like that would solve my need to set scheme handlers.
There is one additional need that emerged after creating this issue that I also resolved with my workaround of subclassing CDVWebViewEngine
. We need to hook into some of the WKNavigationDelegate
calls, particularly webViewWebContentProcessDidTerminate:
. Since CDVWebViewEngine
already implemented that, overriding it was the quickest path forward. If there public API that allows me to do that another way, then I would be able to remove my workaround.
Looks like this might actually be resolved by #1050
I haven't tried this myself yet, but looks like that would solve my need to set scheme handlers.
There is one additional need that emerged after creating this issue that I also resolved with my workaround of subclassing
CDVWebViewEngine
. We need to hook into some of theWKNavigationDelegate
calls, particularlywebViewWebContentProcessDidTerminate:
. SinceCDVWebViewEngine
already implemented that, overriding it was the quickest path forward. If there public API that allows me to do that another way, then I would be able to remove my workaround.
@jasonbekolay The same issue, as the NSURLProtocol of UIWeb no longer exists, WKWebb needs to update it. How did you handle it? Can you share it
@GymotgM It's not been pushed AFAIK
@breautek Hello, as WKWebb no longer uses NSURLProtocol, have you organized or referenced the materials for switching to WKURLSchemeHandler? I am looking forward to more information to solve the bridging problem after replacing UIWeb with WKWebb and listing it on the Apple Store
@GymotgM Cordova iOS has used WKURLSchemeHandler
for serving content since cordova-ios 6.0.0, released in 2020.