Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between WKWebView and Safari?

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 !

like image 860
MaximVW Avatar asked Nov 12 '17 18:11

MaximVW


2 Answers

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"
like image 159
Yitzchak Avatar answered Sep 28 '22 05:09

Yitzchak


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.

like image 44
nicbou Avatar answered Sep 28 '22 05:09

nicbou