Closed sanjaykumarm closed 7 years ago
Is your version of this library up-to-date?
Can you verify this on a real device, as opposed to an emulator?
Is Android System WebView up-to-date on your device?
Can you check whether calling
mWebView.setDesktopMode(true);
before loading the URL makes any difference?
As a last resort, could you replace this library with Android's plain WebView
again, temporarily, to see if that makes any difference?
Thanks!
Is your version of this library up-to-date
Can you verify this on a real device, as opposed to an emulator?
Is Android System WebViewhttps://play.google.com/store/apps/details?id=com.google.android.webview up-to-date on your device?
Can you check whether calling
mWebView.setDesktopMode(true);
before loading the URL makes any difference?
From: Marco [notifications@github.com] Sent: Sunday, March 12, 2017 3:38 AM To: delight-im/Android-AdvancedWebView Cc: Sanjaykumar Modhawadiya; Author Subject: Re: [delight-im/Android-AdvancedWebView] web.whatsapp.com not working (#121)
Is your version of this library up-to-date?
Can you verify this on a real device, as opposed to an emulator?
Is Android System WebViewhttps://play.google.com/store/apps/details?id=com.google.android.webview up-to-date on your device?
Can you check whether calling
mWebView.setDesktopMode(true);
before loading the URL makes any difference?
Thanks!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/delight-im/Android-AdvancedWebView/issues/121#issuecomment-285904050, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALONlwLTuikJdl-jCJ-6a_x2SOeb4MOjks5rkxtbgaJpZM4MZWve.
Click herehttps://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ== to report this email as spam.
Email confidentiality
This message is private and confidential. If you have received this message in error, please notify us and remove it from your system. The dissemination, copying or distribution of this message, or related files, by anyone other than the intended recipient is strictly prohibited.
Any views or opinions expressed are solely those of the author and do not necessarily represent those of Advanced Computer Software Group Limited.
Email monitoring
Advanced Computer Software Group Limited may monitor email traffic data and also the content of email for the purposes of security and staff training.
Email security
In keeping with good computing practice, the recipient of this email should ensure that it is virus-free. Advanced Computer Software Group Limited does not accept responsibility for any virus that may be transferred by way of this email.
Email may be susceptible to data corruption, interception and/or unauthorised amendment. Advanced Computer Software Group Limited does not accept liability for any such corruption, interception or amendment or any consequences thereof.
This email has been scanned for viruses by the Symantec Email Security.cloud service.
Advanced Computer Software Group Limited
Registered office: Ditton Park, Riding Court Road, Datchet, Berkshire, SL3 9LL, UK
Registered in England under number 5965280
Please consider the environment: Think before you print!
This message has been scanned for malware by Websense. www.websense.com
The user-agent string is definitely the reason for the redirect here, I'd say. I don't know why
mWebView.setDesktopMode(true);
doesn't work, but it probably does not look similar enough to desktop browsers, in WhatsApp's terms.
Please try setting another user-agent string manually, e.g.
mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:52.0) Gecko/20100101 Firefox/52.0");
Does that work?
Same result using your user agent string. First time it loads correctly, but from second time on wards, it creates issue and redirects to its official site. So I think in first load, they are storing some data. I also disable the cookies but it didn't help me.
I wondered that how this app https://play.google.com/store/apps/details?id=com.whatscan? make it possible ? It is working fine.
From: Marco notifications@github.com Sent: Tuesday, March 14, 2017 4:51 AM To: delight-im/Android-AdvancedWebView Cc: Sanjaykumar Modhawadiya; Author Subject: Re: [delight-im/Android-AdvancedWebView] web.whatsapp.com not working (#121)
The user-agent string is definitely the reason for the redirect here, I'd say. I don't know why
mWebView.setDesktopMode(true);
doesn't work, but it probably does not look similar enough to desktop browsers, in WhatsApp's terms.
Please try setting another user-agent string manually, e.g.
mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:52.0) Gecko/20100101 Firefox/52.0");
Does that work?
- You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://github.com/delight-im/Android-AdvancedWebView/issues/121#issuecomment-286274214, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALONlyyIWccHFWkgHMgmlDBNSxiR1Um8ks5rlc9zgaJpZM4MZWve.
Click herehttps://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ== to report this email as spam.
Email confidentiality
This message is private and confidential. If you have received this message in error, please notify us and remove it from your system. The dissemination, copying or distribution of this message, or related files, by anyone other than the intended recipient is strictly prohibited.
Any views or opinions expressed are solely those of the author and do not necessarily represent those of Advanced Computer Software Group Limited.
Email monitoring
Advanced Computer Software Group Limited may monitor email traffic data and also the content of email for the purposes of security and staff training.
Email security
In keeping with good computing practice, the recipient of this email should ensure that it is virus-free. Advanced Computer Software Group Limited does not accept responsibility for any virus that may be transferred by way of this email.
Email may be susceptible to data corruption, interception and/or unauthorised amendment. Advanced Computer Software Group Limited does not accept liability for any such corruption, interception or amendment or any consequences thereof.
This email has been scanned for viruses by the Symantec Email Security.cloud service.
Advanced Computer Software Group Limited
Registered office: Ditton Park, Riding Court Road, Datchet, Berkshire, SL3 9LL, UK
Registered in England under number 5965280
Please consider the environment: Think before you print!
This message has been scanned for malware by Websense. www.websense.com
Sorry to hear that it's still not working. Don't know what that other app is doing to make it work. WhatsApp must be doing some checks to find out if you're on a phone or tablet/desktop. Hope you'll find out what it is.
But this is hardly a bug in WebView, and since Android's built-in WebView shows the same behavior, verifiably not a bug in this library here. So the only thing we can do is close this issue. Sorry!
Try this User agent @sanjaykumarm
mWebView.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:52.0) Gecko/20100101 Firefox/52.0");
This User agent is working. I recently tried and successfully load http://web.whatsapp.com in android webView with above mention User Agent
@Bhuvan-Arora This will work on first time start up of the app. From next start up, it goes to official site. Again when you do clear data and load the app, it works but again when you open the app second time then it fails to load the desired web page (i.e. qr code page).
@sanjaykumarm Then you have to try windows-7 User Agent. I think it shall work. Otherwise Notify me again, then I will check the code and try to find out the solution in my vacant schedule.
@Bhuvan-Arora I tried everything but didnt work for me. In your case is it working every time ? And if you logged in by scanning code then is it maintained until you signed out ?
@sanjaykumarm During R&D of your issue I successfully find the relevant solution and finally uploaded the build apk on Google Play. You can test it here. https://play.google.com/store/apps/details?id=coders.phoenix.whatscan
And if it is working according to your requirement then please Don't forget to give your valuable feedback on playstore.
Send me your email id. I will mail the working user agent there.
Hi everyone, I'm having the same issue. Even forcing a desktop browser user-agent the WhatsApp don't open the Webview in Desktop mode but on some random website. Does anyone have a fix for this?
Greetings.
@Bhuvan-Arora plz tell me for that issue which user agent have you used ??
It should be pretty easy to test if this really depends on the user-agent string:
First, open Firefox or Chrome on your desktop machine where the unwanted redirect (upon refresh) for web.whatsapp.com
does not happen. Copy that browser's user-agent string and use it in your Android application. Now, if the unwanted redirect does not occur anymore with that new user-agent string on Android, you're done. If it still happens, that problem does not (only) depend on the user-agent string.
Instead, it might also be feature detection and the redirect might then occur upon discovering missing features. WhatsApp may require the following features, among others:
window.localStorage
window.sessionStorage
window.URL
window.crypto && window.crypto.getRandomValues
window.WebSocket
window.crypto && (window.crypto.subtle || window.crypto.webkitSubtle)
window.Worker
Hi, I'm using this user-agent: webSettings.setUserAgentString("Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36");
And I'm having the behavior that sanjaykumarm is reporting.
Same Issue, It only works once but once I reopen the app i got the redirect :/ Can you share your solution @Bhuvan-Arora
Anyone knows how to fix this?
Greetings.
@vrgomes and @serezin See the comment above for details about the most likely cause for this issue.
@ocram that's impossible because on the first run it works perfectly. The next runs fail. Also if I clear data + cache it works good again.
Greetings.
@vrgomes But it cannot be the user-agent (alone), either, because we have excluded that with various tests, right? If you feel that it's your cookies, stored data and cache, you should inspect what's in there and affects the second page load.
I finally make this work with mWebView.setDesktopMode(true)
but there is a problem with the buttons in the chats, seems not to be clickable and some images are not loading
@statickidz It’s unlikely that mWebView.setDesktopMode(true)
alone did the trick, isn’t it? I’m sure others have tried that as well. For any problems with buttons or images, we’d probably need screenshots to see what the issue may be.
@ocram Yes, it did the trick and also did in the normal WebView component implementing the same code in the user-agent.
I also tried with crosswalk webview and it runs smootly at least in emulators buttons for submenus are actually working also in crosswalk.
Here is some examples you can help to dive in this;
Submenus not clickables, main manu catch the click as you can see
Another example
Not loading images example, only GIFs, I think blob data can be the issue
The mWebView.setDesktopMode(true) does not work. After a refresh it loses the desktop mode. Or simply exiting and entering again also happens. Only by making a full data + cache clear is the only way for it to work again.
I really don't understand how this is possible. Has anyone overcome this?
@vrgomes See https://github.com/delight-im/Android-AdvancedWebView/issues/121#issuecomment-321582531 for the most likely explanation so far. You can check this yourself and see if that’s really the reason or not. Just check the existence of these features via JavaScript.
In my case i tried custom user agent , viewport , display size ,Advanced WebView, mWebView.setDesktopMode(true) nothing is worked for me..
The thing is its working good in android emulator not in real device. In fact it loads the correct QRcode screen first time in real android mobile, if the activity loads the web view again it always redirect the https://www.whatsapp.com rather then https://web.whatsapp.com
I described my problem here: https://stackoverflow.com/questions/47946658/android-webview-desktop-website-wont-work?noredirect=1#comment82880069_47946658
If anyone have the solution please help me how to solve this
@Bhuvan-Arora Am wondering about u, Could you please tell me what i missing in my code https://stackoverflow.com/questions/47946658/android-webview-desktop-website-wont-work?noredirect=1#comment82880069_47946658
@sanjaykumarm Hi did you fix the issue?
@ArunVicky001 AS statickidz mention above, I used crosswalk webview to resolve the issue. I tried all possible combination of user agent in 'Android-AdvancedWebView', but it was not working in all the devices. But crosswalk webview is working fine - only disadvantage is that it increase apk size too much but there is no any alternate solution. Hope it helps.
@sanjaykumarm Thankyou very much for your reply. I'll do with crosswalk webview, Does @Bhuvan-Arora tell any suggestion regarding this.
@ArunVicky001 WC 👍 Happy to help you
Hi, so by using crosswalk webview it means that we have to remove the Android-AdvancedWebView? Does anyone have a tutorial for the crosswalk webview?
Greetings.
If anyone is still interested in a fix, I got it to work by sideloading Firefox and forcing it to use desktop mode via the instructions on this thread https://support.mozilla.org/en-US/questions/1114055 NB there doesn't seem to be an add on that will do the trick any more, you have to edit the about:config
So basically what everyone said about the user agent, but using this one on Firefox: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0
On a Kindle Fire HD 10 7th gen
@highwaycrossingfrog If anyone is still interested in a fix, I got it to work by sideloading Firefox and forcing it to use desktop mode via the instructions on this thread https://support.mozilla.org/en-US/questions/1114055 NB there doesn't seem to be an add on that will do the trick any more, you have to edit the about:config
Could you please explain me how did you achieve this, i wanted to request the desktop site in android WebView not in firefox. Is there is any possibilities to achieve that?
Thanks in advance.
@Bhuvan-Arora Please give any idea to do this ?
Solution
Use below user agent for whatsapp web. It will definitely work.
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36
Or you can also search it on web ""latest user agent of google chrome for window-7"".
Warning : But please don't try to upload it on Google Play, It is not legal according to google play policies and it may cause suspension of your google play account.
@Bhuvan-Arora Thank you very much for your reply but the above user agent only works at first time but since second time [https://web.whatsapp.com] automatically redirect me to [https://www.whatsapp.com] site instead of web.whatsapp.
@Bhuvan-Arora Your solution is not working have you tried that?
@sanjaykumarm During R&D of your issue I successfully find the relevant solution and finally uploaded the build apk on Google Play. You can test it here. https://play.google.com/store/apps/details?id=coders.phoenix.whatscan
And if it is working according to your requirement then please Don't forget to give your valuable feedback on playstore.
Send me your email id. I will mail the working user agent there.
Hello, Can you please send me solution to rashmi.karma2213@gmail.com ?
settings.setDomStorageEnabled(true); webView?.settings?.userAgentString = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" This is working for web.whatsapp and Web.wechat,
settings.setDomStorageEnabled(true); webView?.settings?.userAgentString = "Mozilla/5.0 (Windows NT 10.0; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0" This is working for web.whatsapp and Web.wechat,
this is not work
I recently tried and successfully load http://web.whatsapp.com in android webView with below mention functinality:--
private void setWebView() { webView = (WebView) findViewById(R.id.webViews); webView.getSettings().setJavaScriptEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDisplayZoomControls(false); webView.getSettings().setUserAgentString("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/20100101 Firefox/44.0"); webView.getSettings().setMediaPlaybackRequiresUserGesture(false); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new MyWebViewClient()); webView.getSettings().setSaveFormData(true); webView.getSettings().setLoadsImagesAutomatically(true); webView.getSettings().setUseWideViewPort(true); webView.getSettings().setAllowFileAccessFromFileURLs(true); webView.getSettings().setBlockNetworkImage(false); webView.getSettings().setBlockNetworkLoads(false); webView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL); webView.getSettings().setSupportMultipleWindows(true); webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); webView.getSettings().setLoadWithOverviewMode(true); webView.getSettings().setNeedInitialFocus(false); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setDatabaseEnabled(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setGeolocationEnabled(true); webView.getSettings().setCacheMode(2); webView.setScrollBarStyle(0); webView.getSettings().setUserAgentString("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.96 Safari/537.36"); final StringBuilder sb = new StringBuilder(); sb.append("https://web.whatsapp.com/🌐/"); sb.append(Locale.getDefault().getLanguage()); webView.loadUrl(sb.toString());
}
private class MyWebViewClient extends WebViewClient { @Override public void onPageFinished(WebView webView, String str) { loadingView.setVisibility(View.GONE); } @Override public void onPageStarted(WebView webView, String str, Bitmap bitmap) {}
private MyWebViewClient() {
}
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
loadingView.setVisibility(View.VISIBLE);
String str2 = "WhtasWeb";
Log.e(str2, "shouldOverrideUrlLoading: " + str);
if (Uri.parse(str).getHost().contains(".whatsapp.com")) {
return true;
}
getActivity().startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
return true;
}
}
@AnkitaManiya Thanks for sharing your answers hope this will help us
@AnkitaManiya Can you please share your email ? Wanted little more help, so that I can contact you there. Wanted to help more developers if they can also get more benefits of problems they are facing.
Try this settings
webViewWorker = findViewById(R.id.webViewWorker);
webViewWorker.getSettings().setJavaScriptEnabled(true);
webViewWorker.getSettings().setLoadsImagesAutomatically(true);
webViewWorker.getSettings().setLoadWithOverviewMode(true);
webViewWorker.getSettings().setUseWideViewPort(true);
webViewWorker.getSettings().setDomStorageEnabled(true);
webViewWorker.getSettings().setBuiltInZoomControls(true);
String userAgent = webViewWorker.getSettings().getUserAgentString();
try {
String androidString = webViewWorker.getSettings().getUserAgentString().substring(userAgent.indexOf("("),userAgent.indexOf(")") + 1);
userAgent = webViewWorker.getSettings().getUserAgentString().replace(androidString,"X11; Linux x86_64");
} catch (Exception e) {
e.printStackTrace();
}
webViewWorker.getSettings().setUserAgentString(userAgent);
webViewWorker.loadUrl("https://web.whatsapp.com");
web.whatsapp.com is not working when you load the url second time. It redirects to whatsapp.com when you load the url.