Github user ephemer commented on the pull request:
https://github.com/apache/cordova-plugin-wkwebview-engine/pull/8#issuecomment-215702371
@shazron in that case we'd have to remove the configuration code from
updateWithInfo because we've already established that it doesn't do anything
anyway. It'd be very frustrating for a new developer to see that code and
wonder why it does nothing at all. As far as I can see it will never work,
wkWebView.configuration is listed as `read-only` in Apple's docs. I'd also
rename `updateWithInfo` to `updateDelegates` or similar unless it breaks
something else.
If we just inited the WKWebView once in `pluginInitialize`, I'm pretty
certain the `CDVViewController.m` would fail at the `canLoadRequest:` check and
then proceed to replace the `WKWebViewEngine` with `defaultWebViewEngineClass`,
as commented in #7:
if ( (...) || ![self.webViewEngine canLoadRequest:[NSURLRequest
requestWithURL:self.appUrl]]) {
self.webViewEngine = [[NSClassFromString(defaultWebViewEngineClass)
alloc] initWithFrame:bounds];
}
Specifically this is due to the following code in `CDVWKWebViewEngine`:
https://github.com/apache/cordova-plugin-wkwebview-engine/blob/33a75172a1450e8922788cd23382cc6ec33845c7/src/ios/CDVWKWebViewEngine.m#L136
`_engineWebView` would still be nil here (because `pluginInitialize`
wouldn't have been called), which would as far as I understand (I'm
Swift-first, ObjC when necessary) be coerced to `NO`, making the above check
fail.
As far as I can see, the only clean solution to this would be to pass
`settings` into the WebViewEngine's `init` method. That is probably also the
most logical and explicit way about getting the settings from `config.xml` into
the WebView.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]