I develop an android application that has to open url in a webView.
the page open without any issues on the browser, but in my webView it opens a blank page and logs the following error in the logcat.
I/chromium: [INFO:CONSOLE(2)] "FirebaseError: Messaging: This browser doesn't support the API's required to use the firebase SDK. (messaging/unsupported-browser).", source: https://myWebsite/static/js/2.4d0092a9.chunk.js (2)
And here it is my code
#SuppressLint("SetJavaScriptEnabled")
private void setUpWebViewSettings() {
WebSettings websettings = regularWebView.getSettings();
websettings.setJavaScriptEnabled(true);
websettings.setDomStorageEnabled(true);
websettings.setAllowFileAccess(true);
websettings.setAppCacheEnabled(true);
websettings.setUseWideViewPort(true);
websettings.setLoadWithOverviewMode(true);
websettings.setSaveFormData(true);
}
private void setUpMuWebView() {
regularWebView.clearCache(true);
regularWebView.clearHistory();
setUpWebViewSettings();
regularWebView.setWebViewClient(new WebViewClient() {
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
#Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
super.onReceivedError(view, request, error);
Log.d(TAG, error.toString());
}
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
});
regularWebView.loadUrl(<UrlToLoad>);
}
What should I do to load the page? and is there any suggested webView library that can help me to open the page inside my application?
The error message is not related to the blank page issue, your webView is unable to render the page because of cashing issue.
I had experienced with the same issue when I worked with a react.js team, and clean the cash and made a hard reload on my PC browser to be able to open the webPage on my app webView.
and here it is the steps to do it:
Open the URL on the browser on your PC.
press F12 to open the Firebug.
Long press on the refresh page.
select empty cash and hard reload
After that try to open the URL from your App WebView.
these steps fixed the issue for me, and it should fix the issue for you if it's a cashing issue, otherwise, you have to you customtabsintent or contact the page admin to investigate and fix the issue if you can contact him.
And the unsupported-browser error message appease because of using Firebase cloud messaging feature. The Firebase Cloud Messages API in the JavaScript SDK uses APIs which are only supported by a subset of modern browsers, and webView component is using chromium which is not supporting the Firebase cloud messaging. Check out this related thread for more details.
Related
I am currently testing the DocuSign API with the Demo Sandbox.
I have a WebAPI in C# which uses the DocuSign API. I create an enveloppe containing the document to sign and generate the recipient View URL.
I also have an Android App with a Webview which is supposed to get the generated URL to permit the user to sign the document.
When the webview loads the URL, the error ERR_CONNECTION_RESET occurs.
I precise that it works well using the Android Emulator but not with my phone connected in WI-FI.
Thanks in advance.
I copy/pasted the URL to my phone browser and it works. It's only within the App and the Webview that I can reach it.
I expect to reach the Docusign signing page related to my Document.
The WebView shows an ERR_CONNECTION_RESET
EDIT :
Here is some code
myWebView.getSettings().setJavaScriptEnabled(true);
myWebView.getSettings().setDomStorageEnabled(true);
myWebView.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest url) {
if((url.getUrl()).toString().equals(Constant.URL + "?event=signing_complete"))
{
/*Some code to redirect to other activity*/
return true;
}
else
{
Log.i("url",rep);
myWebView.loadUrl(rep);
return false;
}
}
#Override
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error){
//myWebView.loadUrl(rep);
Log.d("ERROR", error.getErrorCode());
}
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
Log.i("SSL", "SSL error");
handler.proceed();
}
});
[here is the result in the webview][1]
[1]: https://i.stack.imgur.com/yRuly.png
EDIT 2 :
If it can help, My .NET WEB API is hosted on my computer with Windows IIS and is connected to the network through Ethernet.
The Android device is connected via WI-FI to the same network.
I don't know if the error is because of the usage of SSL to access the signing page of Docusign.
I tried to replace the url of the webview by google.com and it worked fine.
It would be great if you added some code, so we can easily trace the error.
Have you tried adding
WebSettings webSettings = mWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setDomStorageEnabled(true);
to your web view?
I finally solved my problem but still don't understand the reasons.
I manually uninstalled the application from the device.
I reinstalled it and it worked, just feels so stupid that I didn't try that at first...
"Have you tried turning it off and on again ?"
I have tested my app with many https URLs, almost all are working fine but not the one I want. I have tested my URL, it's working fine with all the browser except Internet Explorer.
Already handling SSL Error
Override shouldOverrideUrlLoading too.
webView.getSettings().setJavaScriptEnabled(true);
I want to know whether it's the problem in the URL or from Android.
I have solved my problem by enabling DomStorage.
webview.getSettings().setDomStorageEnabled(true);
I have searched about domStorage, as i understand it works if website using HTML5. Don't know too much about dom storage.
Just try to ignore SSL, check below snippet.
webView.setWebViewClient(webViewClient);
private WebViewClient webViewClient = new WebViewClient() {
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed(); // Ignore SSL certificate errors
}
#Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
};
Did you enable javascript on the webview?
webView.getSettings().setJavaScriptEnabled(true);
Most probably, its the problem in the URL not with the Android. As you are saying there is no SSL certificate issue and all other https URL's are working except yours.
You should contact your service provider or check from web end.
I've developed a small group of .html pages that are stored in a server.
My android app, using a webview with: setWebChromeClient loads these pages.
minSdkVersion 19
targetSdkVersion 24
The problem:
Everytime I need to load a new page, using a link in my .html page, the new page is opened in an external browser.
Url Overriding
I know about the shouldOverrideUrlLoading() method, when we're using the setWebViewClient().
But unfortunately I can't use the normal webview. I need to use the WebChromeClient() because of some feature that only work with this one. (Like the input file)
My doubt is...
How can I override my URL to force them to load inside of the webChromeClient?
I tried this but with no luck:
webView.setWebChromeClient(new WebChromeClient() {
// (...)
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
You can use following code to achieve this.
WebView web = (WebView)findViewById(R.id.web);
WebSettings webSettings = web.getSettings();
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportMultipleWindows(true); // This forces ChromeClient enabled.
web.setWebChromeClient(new WebChromeClient(){
#Override
public void onReceivedTitle(WebView view, String title) {
getWindow().setTitle(title); //Set Activity tile to page title.
}
});
web.setWebViewClient(new WebViewClient() {
#Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return false;
}
});
I was using an embedded mobile web application in an Android App making use of the WebChromeClient class and did not want to fiddle around with recompiling the APK.
While looking for the easiest header(); solution (since the mobile web application is in php) I found out that using:
header("Location: url.php", TRUE, 307);
was a quick fix solution without recompiling the Android app.
This allowed the user to re-direct within the app without calling the web browser externally from my app.
Here is the link to the answer by Arindam Nayak where I got the idea from.
Before starting use https my application it worked with http request. Everything is worked fine. But when I decided to change all url to https I have one unsolved problem. I can't show images in webview it doesn't show nothing. What should I do here to show images using https request.
Loading https url shows blank page because you should decide if your app wants to proceed to an untrusted web site via a WebView. You can set this by overriding onReceivedSslError method in WebViewClient. I tested your image and it shows proper image.
webView.setWebViewClient(new CustomWebViewClient());
...
private class CustomViewClient extends WebViewClient
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
handler.proceed();
}
}
However, this only works from Android 2.2(Froyo). For Android version below 2.2, a public API is not provided.
I need to show a webview that let the user enter this website: http://m.orange.es/area_clientes/
If I try to enter to that website and login with my user with the phone navigator, it works fine, and the navigator asks me to accept a certificate.
If I try to enter that website and login with a webview in my android app, the webview can't do the login with my user and my password, the "accept certificate" popup does not appear, and I'm getting redirected to a error website.
How can this be solved?
I checked a lot of questions on stackoverflow related with this isseue, but none of them worked:
WebView with SSL Client Certificate on Android 4 ICS
Does the Web View on Android support SSL?
Android WebView SSL 'Security Warning'
http://damianflannery.wordpress.com/2010/09/28/android-webview-with-https-loadurl-shows-blankempty-page/
My webview:
webView.getSettings().setJavaScriptEnabled(true);
webView.getSettings().setSupportZoom( allowZooming );
webView.loadUrl(URLParser.parse(this.URL));
webView.getLayoutParams().height=LinearLayout.LayoutParams.MATCH_PARENT;
webView.getLayoutParams().width=LinearLayout.LayoutParams.MATCH_PARENT;
/////////////////////
webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(false);
webView.getSettings().setLoadsImagesAutomatically(true);
webView.setWebChromeClient(new WebChromeClient());
/////////////////////
webView.setWebViewClient(new WebViewClient(){
#Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
super.onReceivedSslError(view, handler, error);
handler.proceed();
}
});