You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by GitBox <gi...@apache.org> on 2021/10/19 20:43:14 UTC
[GitHub] [cordova-ios] alekop opened a new issue #1163: Cannot use custom scheme in embedded web view
alekop opened a new issue #1163:
URL: https://github.com/apache/cordova-ios/issues/1163
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:
<preference name="scheme" value="app" />
<preference name="hostname" value="localhost" />
`CDVWebViewEngine.pluginInitialize` creates the scheme handler, and attaches it to the configuration:
self.schemeHandler = [[CDVURLSchemeHandler alloc] initWithVC:vc];
[configuration setURLSchemeHandler:self.schemeHandler forURLScheme:scheme];
Finally, `CDVWebViewEngine.loadRequest` calls WKWebView.loadRequest with "app://localhost/index.html"... But the `CDVURLSchemeHandler.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:
class CordovaWebViewController: CDVViewController {
init() {
super.init(nibName: nil, bundle: nil)
}
required init?(coder: NSCoder) {
super.init(coder: coder)
}
}
struct CordovaWebView: UIViewControllerRepresentable {
typealias UIViewControllerType = CordovaWebViewController
func makeUIViewController(context: Context) -> CordovaWebViewController {
CordovaWebViewController()
}
func updateUIViewController(_ uiViewController: CordovaWebViewController, context: Context) {
}
}
And used like this:
```
struct ContentView: View {
var body: some View {
CordovaWebView()
}
}
```
Is there anything extra I need to do for an embedded view?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-ios] alekop commented on issue #1163: Cannot use custom scheme in embedded web view
Posted by GitBox <gi...@apache.org>.
alekop commented on issue #1163:
URL: https://github.com/apache/cordova-ios/issues/1163#issuecomment-947133775
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org
[GitHub] [cordova-ios] alekop commented on issue #1163: Cannot use custom scheme in embedded web view
Posted by GitBox <gi...@apache.org>.
alekop commented on issue #1163:
URL: https://github.com/apache/cordova-ios/issues/1163#issuecomment-948113026
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??
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org