Difference between WKWebView and Safari? - ios

I'm creating a special app where I'm using a WKWebView.
But I have one problem... WKWebView is acting different (outdated browser) than Safari (iOS version of Safari ofc).
If I visit adidas.com/yeezy on Safari, there is no problem.
But when I visit this site in WKWebView, it says that the browser is not modern enough.
I really need to fix this otherwise my app can't work.
Does anyone has a solution to make WKWebView "modern" ?
Thanks !

I believe it's just configuration. check out WKPreferences
I guess that if you enable whatever you can, you'll find the requested feature.. I'll check adidas to see if I find something special needed
EDIT:
Second option, you may trick the website that you are a different browser.
just set customUserAgent, see here.
You can see a working example in your Mac.
1) Open Safari
2) Development
3) User Agent
4) Other
Copy and past it to your code, Good luck!
Take for an example the next value:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.3.5
(KHTML, like Gecko) Version/11.0.1 Safari/604.3.5
EDIT: Example for swift 5 and XCode 10.2.1
Thanks Mr.G
testWebView.customUserAgent = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.1 Mobile/15E148 Safari/604.1"

I found this question while investigating a similar issue: my website works fine in Safari but not in Chrome for iOS.
If you visit http://whatsmyuseragent.org, you will likely notice that your WKWebView is using a different webkit version (60x.x.x) than Safari.

Related

Audio/Video not supported React Native ios webview

I'm working on a live video session app. I have used the BigBlueButton API to develop the web version, which is working properly on the web. I'm trying to use that web app URL in my react native app using react-native-webview. In iOS app, I'm able to join the session but while enabling video I'm getting error message as follows
**Audio/Video not supported**
At this time audio and video not supported on chrome for ios. We recommend using Safari iOS.
When I'm setting userAgent as "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_0) AppleWebKit/604.3.5 (KHTML, like Gecko) Chrome/83.0.4103.97 Version/12.0.1 Mobile Safari/604.3.5".
And when I'm setting userAgent as "Mozilla/5.0 (iPhone; CPU iPhone OS 13_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/83.0.4103.88 Mobile/15E148 Safari/604.1" I'm getting following error.
On iOS please use Safari for full support.
When I'm removing the userAgent it showing the error like
It looks like you're using a browser that is not supported. Please use either Chrome or Firefox for full support.
Thanks in advance.

What is special with this user agent? page keep refreshing only with this UA

I am having an issue with this UA
Mozilla/5.0 (iPhone; CPU iPhone OS 8_4_1 like Mac OS X) AppleWebKit/600.1.4 (KHTML, like Gecko) CriOS/47.0.2526.107 Mobile/12H321 Safari/600.1.4
Site is written in React and using query like ?nexturl to navigate on access.It works fine on all other UA that i can find on simulators, but not this one.
Simply it doesn't work on my iphone6 and my ipad as well, which is hmm big issue. And if i switch to desktop UA, it works fine.
Even IOS 6,7 UA all works fine on simulate.
It is causing a looping refresh with the navigation above. No error produced, just refreshing.
Anyone have ideas what could be the problem?

Video works in Mobile Safari but not UIWebView

I'm trying to load this page in a UIWebView:
http://www.usopenofsurfing.com/on-demand/dvr
It works using Flash on a desktop browser, but has a different implementation when it detects iOS. It works just fine on Mobile Safari, but it's not working in the UIWebView.
Any idea why?
I've looked at the reported User Agents between actual Mobile Safari and the UIWebView.
UIWebView: iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206
Safari: iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3
The javascript which is switching between the flash and the iOS functionality simply looks for the strings ipad, iphone, or ipod:
var deviceAgent = navigator.userAgent.toLowerCase();
var is_iOS = deviceAgent.match(/(iphone|ipod|ipad)/);
So the User Agent should only come into play when choosing between Flash and iOS and that appears to be done properly.
Cookies may be the problem here.
To the best of my understanding, Cookies can not be sent with the first request from a Webview, but can be sent with subsequent requests to the same URL, if and only if, the first request was successful.
This causes problems with authentication services that require cookies to authenticate on the first request to the URL.
Also see this stack article and this apple documentation.

Mobile Twitter site refuses Webview as client

I'm trying to view a users tweets from my app but twitter responses with a webpage saying:
Sorry that page is not supported on mobile at this time
However if i load the same URL with mobile safari i get a nice webpage with all the tweets.
I'm using this URL: http://mobile.twitter.com/SOME_USERNAME/tweets
You can reproduce the error message by visiting the url in safari. If you use safari as developer and you set the user agent to iPhone you'll get the right page.
It seems the webview is sending different headers as User Agent:
Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B176
vs
Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9B176 Safari/7534.48.3
Is there anything i could do about this problem?
Apperently it does work when i remove the /tweets part of the URL.
This is not really the answer to my question but it is the best option as long as nobody comes up with a better answer i'll accept this answer.

Sometimes iPhone simulator is provided with non-iPhone web content. How to fix this?

I'm pretty sure, that there were times, when I ran iOS Simulator, pointed Safari to some website and Safari was loading a iPhone-specific webpage. However recently it started to load content for desktop browsers, I'm quite sure, it's for plain Safari, not mobile one. iOS Simulator is pretending to be an iPhone with user-agent string like
Mozilla/5.0 (iPhone Simulator; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3
When I put this string as user-agent string into desktop Safari and load, say, SO website, I can see non-mobile version, when I remove Simulator substring, I can see mobile-optimized SO main page.
I've no idea, what have happened, but I'd like to know, how to fix it, since I've spent a whole day catching a bug with JavaScript, and i realized that I was debugging on very different DOM.

Resources