Snapchat Url load issue

不想你离开。 提交于 2019-12-13 22:01:25

问题


I have integrated Follow us on Snapchat in my Android application and for that am displaying https://www.snapchat.com/add/danubeco URL in my default web view. This works fine in the Google Chrome but fails to load in the default browser of the device. Here is the error which am getting on trying in the web view - "Uncaught TypeError: Array.from is not a function", source: https://www.snapchat.com/deeplink/static/js/sc-web-frame.js. I have tried in the several devices and found the same, but the thing is that it works totally fine in IOS. I have attached the screenshot of the web view with the error. Please suggest the way through which I can cope up from the issue.

URL shown in the screenshot - snapchat://add/danubeco?sc_referrer=&link=%2Fadd%2Fdanubeco&sc_ua=Mozilla%2F5.0+%28Linux%3B+Android+6.0%3B+Android+SDK+built+for+x86+Build%2FMASTER%3B+wv%29+AppleWebKit%2F537.36+%28KHTML%2C+like+Gecko%29+Version%2F4.0+Chrome%2F44.0.2403.119+Mobile+Safari%2F537.36&cid=b69e8a19-adf5-4209-9600-a26c0d5e0485

I have simply taken web view in xml and written below code in java class.

webView = (WebView) root.findViewById(R.id.webView);
webView.setKeepScreenOn(true);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.getSettings().setDomStorageEnabled(true);
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setLoadWithOverviewMode(true);
webView.getSettings().setUseWideViewPort(true);
webView.getSettings().setBuiltInZoomControls(true);
webView.getSettings().setSupportZoom(true);
webView.setWebViewClient(new MyWebClient());
webView.loadUrl(url);

Any sort of help would be appreciable.

Thanks.


回答1:


Try this not load url on shouldOverrideUrlLoading and put condition for false this is working perfect

   WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    //ws.setJavaScriptEnabled(true);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    webview.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);



webview.setWebViewClient(new WebViewClient() {

        public boolean shouldOverrideUrlLoading(WebView view, String url) {


            if( url.startsWith("http:") || url.startsWith("https:") ) {
                return false;
            }
          //  Log.i(TAG, "Processing webview url click..."+url);
         //  view.loadUrl(url);

            return true;
        }


        public void onPageFinished(WebView view, String url) {
            Log.e(TAG, "Finished loading URL: " + url);
            if (progressBar.isShowing()) {
                progressBar.dismiss();
            }


        }


        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {



        }
    });

    webview.loadUrl("https://www.snapchat.com/add/danubeco");


来源:https://stackoverflow.com/questions/38785334/snapchat-url-load-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!