简体   繁体   English

Gluon - 如何创建 webview 与原生通信(iOS)

[英]Gluon - how to create webview to communicate with native (iOS)

The mobile app interface implemented via Gluon must be written in JavaFX, this is not our option, as we need to use HTML/JavaScript/CSS/Reactjs to build the interface.通过 Gluon 实现的移动应用程序界面必须使用 JavaFX 编写,这不是我们的选择,因为我们需要使用 HTML/JavaScript/CSS/Reactjs 来构建界面。

So I am trying to create an webview (either UIWebView or WKWebView for iOS) in Gluon, so I can load the offline HTML asset, and then I am trying to use the method as described here ( https://medium.com/@sreeharikv112/communication-from-webview-to-native-ios-android-app-6d842cefe02d ) to communicate between webview and native code (Java by Gluon). So I am trying to create an webview (either UIWebView or WKWebView for iOS) in Gluon, so I can load the offline HTML asset, and then I am trying to use the method as described here ( https://medium.com/@ sreeharikv112/communication-from-webview-to-native-ios-android-app-6d842cefe02d )在 webview 和本机代码(Java by Gluon)之间进行通信。

But I can't find any guide to do so in Gluon API, is that possible?但是我在 Gluon API 中找不到任何指南,这可能吗? How can I achieve that?我怎样才能做到这一点?

Alright after some time, I have figured out how to achieve this.好吧,过了一段时间,我想出了如何实现这一点。

Previously I was in wrong direction, checking through all Gluon Charm-down/Attach service to look for the WebView wrapper but couldn't find.以前我的方向错误,检查所有 Gluon Charm-down/Attach 服务以查找 WebView 包装器但找不到。

Then I realise the WebView implementation was provided in JavaFX Port, which mean we can use JavaFX in normal way (like how we do in JavaFX desktop), so we can setup the bridge as per usual and communicate between javascript and Java. Then I realise the WebView implementation was provided in JavaFX Port, which mean we can use JavaFX in normal way (like how we do in JavaFX desktop), so we can setup the bridge as per usual and communicate between javascript and Java.

Internally, it is using iOS UIWebView for the implementation, it is not the rework of the JavaFX WebView.在内部,它是使用 iOS UIWebView 来实现的,它不是 JavaFX Z3E7D16622A52399BEBEF786CAFFBF6 的返工

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM