apache / cordova-ios

Apache Cordova iOS
https://cordova.apache.org/
Apache License 2.0
2.15k stars 987 forks source link

evaluateJavaScript do not work. without UIWebView component #1143

Closed dadigua2333 closed 2 years ago

dadigua2333 commented 2 years ago

When I communicate with the web. IOS actively notifies the web. I use it [self.commandDelegate evalJs:@""]; It doesn't work. But I use the old version. When UIWebview component is included, it can. Does WKWebview need to make some other settings?

breautek commented 2 years ago

If you wanted to send a message to the webview, you should be going through the plugin interface for the callback system, e.g. the webview registers a callback which the cordova plugin can keep the callback alive and reuse as necessary for continuous events.

But as for as evaluating javascript with WKWebview, I think you'll find this interesting, but not recommended in the context of cordova plugins.