1

I have an react-native app. It has a JavaScript alert in one of the webviews. It works in IOS but not android. I have changed the proguard-rule.pro file as follows

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. How do I do this, and what are the fully qualified class name to the JavaScript Interface. I am pretty sure I have not modified the Javascript interface in my version of the app.

Obromios
  • 15,408
  • 15
  • 72
  • 127

2 Answers2

0

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. It is fairly easy to do that in RN though. You can use this example and this package for implementation reference.

Community
  • 1
  • 1
martinarroyo
  • 9,389
  • 3
  • 38
  • 75
0

Try webView.setJavaScriptEnabled(true) in your WebView.

Satan Pandeya
  • 3,747
  • 4
  • 27
  • 53
  • 1
    While this code snippet may solve the question, [including an explanation](http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers) really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion. – yennsarah Dec 08 '16 at 09:46