Closed alekop closed 8 months ago
I noticed that the web view is recreated:
// re-create WKWebView, since we need to update configuration
WKWebView* wkWebView = [[WKWebView alloc] initWithFrame:self.engineWebView.frame configuration:configuration];
Maybe SwiftUI is using the previous version.
After two days, I am no closer to a solution. I've tried starting with a regular HelloCordova app, and removing CDV delegates to isolate the "magic", but the damn thing still loads from app://localhost, while my app with the embedded webview just doesn't. WTF is the difference???
My app: [((WKWebView*)_engineWebView).configuration urlSchemeHandlerForURLScheme:@"app"] return non-null. Why isn't the delegate called then??
I saw this issue with schemes, which had the same behavior: https://github.com/apache/cordova-ios/issues/1223#issuecomment-1608211672
Closing this as a duplicate of https://github.com/apache/cordova-ios/issues/1163
Favouring https://github.com/apache/cordova-ios/issues/1163 because it seems more progressed and it's a more recent reported ticket.
Native SwiftUI app with embedded Cordova Web view. Loads fine using the file scheme, but I would like to use a custom scheme in order to establish a secure context. I've added the scheme and hostname preferences to config.xml file:
CDVWebViewEngine.pluginInitialize
creates the scheme handler, and attaches it to the configuration:Finally,
CDVWebViewEngine.loadRequest
calls WKWebView.loadRequest with "app://localhost/index.html"... But theCDVURLSchemeHandler.startURLSchemeTask
method is never called, and the web view remains on about:blank. Tried setting location.href manually (via the Safari dev tools), but nothing loads.The view controller is exposed to SwiftUI like so:
And used like this:
Is there anything extra I need to do for an embedded view?