How to find out all versions of iPad from user-agent string?

Posted by User11091981 on Stack Overflow See other posts from Stack Overflow or by User11091981
Published on 2012-12-03T12:06:22Z Indexed on 2012/12/11 11:04 UTC
Read the original article Hit count: 272

Filed under:
|
|

I wanted to find out all the version's of iPad (excluding iPhone, iPod) from user agent string, currently while testing I got the following string

Mozilla/5.0 (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

Question: Will the following code works fine for all the iPad's?

String userAgentStr = request.getHeader("User-agent");
if (userAgentStr.contains("iPad"))
{
    //do my logic
}

EDIT:

I am using Dolphin browser from iPad but I am getting the following UA string:

Mozilla/5.0 (iPhone; U; CPU iPhone OS 4_2_1 like Mac OS X; en_US) AppleWebKit/533.17.9 (KHTML, like Gecko) Mobile/8C148 Safari/6533.18.5

Similarly iBrowser from iPad UA string is:

Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Mobile/9B206

So my above code is breaking...

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about iPad