[英]Javascript alert not working in android react-native webview
I have an react-native app. 我有一个反应原生的应用程序。 It has a JavaScript alert in one of the webviews.
它在其中一个网页视图中有一个JavaScript提醒。 It works in IOS but not android.
它适用于IOS,但不适用于android。 I have changed the proguard-rule.pro file as follows
我已经更改了proguard-rule.pro文件,如下所示
class:
-keepclassmembers class fqcn.of.javascript.interface.for.webview {
public android.webkit.WebView, startActivity, android.webkit.WebChromeClient, android.webkit.JsResult;
}
and done a build react-native run-android
but the alert is still not working in the android app. 并完成了一个构建
react-native run-android
但是警报仍然无法在Android应用程序中运行。 How do I do this, and what are the fully qualified class name to the JavaScript Interface. 我该怎么做,以及JavaScript接口的完全限定类名是什么。 I am pretty sure I have not modified the Javascript interface in my version of the app.
我很确定我没有在我的应用程序版本中修改Javascript界面。
According to this thread (which I reached from here ) you have to create a custom WebView component that uses an instance of WebChromeClient
in native code. 根据这个线程 (我从这里开始 ),您必须创建一个自定义WebView组件,该组件在本机代码中使用
WebChromeClient
实例。 It is fairly easy to do that in RN though. 但是在RN中这很容易做到。 You can use this example and this package for implementation reference.
您可以使用此示例和此程序包进行实现参考。
在WebView
尝试webView.setJavaScriptEnabled(true)
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.