Jignesh Jain Jignesh Jain - 3 months ago 48
Javascript Question

Snapchat Url load issue

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.

enter image description here

Answer

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");
Comments