简体   繁体   English

Javascript警报无法在android react-native webview中运行

[英]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.

相关问题 Javascript在Android的React-Native WebView中不起作用(设置了javaScriptEnabled = true) - Javascript is not working in React-Native WebView for Android (javaScriptEnabled = true is set) React-Native:Webview Javascript-Injection无法按预期工作 - React-Native: Webview Javascript-Injection not working as expected 使用 react-native 的 android 中的警报提示(输入值更新警报)不起作用(在 iOS 中工作) - Alert prompt (Alert with input value update) not working in android using react-native (Working in iOS) JavaScript 警报在 Android WebView 中不起作用 - JavaScript alert not working in Android WebView React-Native:在运行时在webview中动态注入javascript - React-Native: Injecting javascript dynamically in webview on runtime 你如何在 React-Native WebView 中执行 Javascript? - How do you execute Javascript in React-Native WebView? React-Native中的WebView没有显示 - WebView in React-Native is not showing react-native图像不适用于android - react-native images not working for android react-native 可滑动手势在 android 上不起作用? - react-native swipeable gesture not working on android? 注入 Javascript 函数在 Android React Native WebView 中不起作用,但在 iOS React Native 中工作正常 - Inject Javascript Function not working in Android React Native WebView but work fine in iOS React Native
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM