Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Distinguish between iPhone web browser and iPhone app user agent

What is the best way to distinguish on a server between a request that came from an iPhone through the web browser vs through an iphone with an app written in objective c? What differences do I look for in the user agent string?

like image 531
user391986 Avatar asked Jul 22 '10 04:07

user391986


1 Answers

It seems that iPhone Apps using the UIWebKit HTTP request component have user agent string like the following

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_0_1 like Mac OS X; fr-fr) AppleWebKit/532.9 (KHTML, like Gecko) Mobile/8A306
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_2 like Mac OS X; fr-fr) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7D11
Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_1_3 like Mac OS X; fr-fr) AppleWebKit/528.18 (KHTML, like Gecko) Mobile/7E18

While Safari on iPhone has mostly the same string but ending with " Safari/XXX"

However, it is also possible to change the user agent of UIWebKit then there is no guarantee that you'll grab every iPhone app by proceeding this way.

like image 186
2 revs, 2 users 96% Avatar answered Sep 23 '22 06:09

2 revs, 2 users 96%