Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does UIWebView send the same User-Agent in the Request Headers as mobile Safari?

Sorry, I would just test this myself, but I'm currently without my mac. Does a web request made inside of a UIWebView send the same user-agent info that a web request made from mobile Safari would?

like image 228
dl. Avatar asked Jan 27 '10 00:01

dl.


People also ask

What is Mobile Safari UIWebView?

It means that your web site was viewed using the UIWebView functionality on an iOS device (iPhone, iPad, iPod Touch). The UIWebView is different from the ordinary Safari browser, as it is not a stand-alone browser, but merely browser functionality that is embedded in a third party app.

What is user agent in Safari develop?

The user agent is a string of text that your browser sends with each web page request. The user agent string is how web sites can identify which web browser and operating system you are using.


2 Answers

Web requests made from UIWebView will not include the word "Safari" in the User Agent string. Web requests made from Mobile Safari will. This is the best way I have found for determining of a request is coming from within an app or from Mobile Safari.

Sample User Agent from UIWebView within App:

User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile 

Sample User Agent from Mobile Safari:

User-Agent: Mozilla/5.0 (iPad; U; CPU OS 4_3_2 like Mac OS X; en-us) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8H7 Safari 
like image 98
dl. Avatar answered Oct 04 '22 00:10

dl.


Standalone mobile Safari user agent strings contain the word 'Version', whereas uiWebView user agent strings do not. So, the detection script can be modified to work with the latest version of iOS like so:

var is_uiwebview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i.test(navigator.userAgent); 
like image 28
unceus Avatar answered Oct 04 '22 00:10

unceus