android: stop logging console logs from webview

Summary: We're logging all console logs from webview. This strips console logging for non debug builds

Reviewed By: AaaChiuuu

Differential Revision: D4578071

fbshipit-source-id: 79b21012a6ef215eb35701911662a720cb6be280
This commit is contained in:
Kevin Gozali 2017-02-17 18:21:20 -08:00 committed by Facebook Github Bot
parent 1fa95ed390
commit cb68b97289
1 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,7 @@ import android.net.Uri;
import android.os.Build;
import android.text.TextUtils;
import android.view.ViewGroup.LayoutParams;
import android.webkit.ConsoleMessage;
import android.webkit.GeolocationPermissions;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
@ -331,6 +332,15 @@ public class ReactWebViewManager extends SimpleViewManager<WebView> {
protected WebView createViewInstance(ThemedReactContext reactContext) {
ReactWebView webView = new ReactWebView(reactContext);
webView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onConsoleMessage(ConsoleMessage message) {
if (ReactBuildConfig.DEBUG) {
return super.onConsoleMessage(message);
}
// Ignore console logs in non debug builds.
return true;
}
@Override
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
callback.invoke(origin, true, false);