I’m trying to load TikTok website in WebView. But I can’t. In logcat I got this error:
"[Report Only] Refused to load the script 'https://sf16-scmcdn-va.ibytedtos.com/goofy/slardar/fe/sdk/plugins/monitors.3.5.4.maliva.js' because it violates the following Content Security Policy directive: "script-src 'self' blob: data: 'unsafe-inline' 'unsafe-eval' polyfill.io *.kakao.com *.cdn-apple.com *.tiktokcdn.com *.byteoversea.com *.tiktok.com". ", source: https://www.tiktok.com/ (0)
Seems Chromium blocking some javascript files that’s why I got white screen. How can I disable or any solutions for it?
My Webview:
webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewWebClient()); webView.getSettings().setSaveFormData(false); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setPluginState(WebSettings.PluginState.ON); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.getSettings().setUserAgentString(System.getProperty("http.agent")); webView.loadUrl("https://www.tiktok.com/");
Advertisement
Answer
webView.getSettings().setDomStorageEnabled(true);
Fixed it. Thanks all.