Developing websites to accommodate for mobile devices has now become standard practice. However, what happens when developers need to determine between different mobile devices (tablets, smartphones, e-readers, games consoles etc)?
We are often asked; how can developers differentiate between two separate Android device types using just their user agent?
Let's take the example of trying to differentiate between the Samsung Galaxy s3 and the Samsung Galaxy tab 2 10.1.
Mozilla/5.0 (Linux; U; Android 4.0.4; en-gb; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30
Mozilla/5.0 (Linux; U; Android 4.0; xx-xx; GT-P5100 Build/IML74K) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30
The above table shows each devices user agent string. Developers can use Regex to search the user agent string to help define mobile devices. In the above example, if we searched the user agent string for “Android” we would be able to determine that the device is using the Android platform. If we wanted to tell if the device was a tablet we would have to look at the model number in the user agent.
A developer would have to build a rule to define user agents which contain “GT-P5100” as a tablet because the user agent doesn't give any other information to be able to determine the associated device is a tablet. Such an approach is highly impractical given the very large range of Android devices.
51degrees.mobi solves this problem by maintaining an up-to-date device database. Our data team map the user agents to unique device profiles freeing customers from the burden of maintaining complex regular expression. The device database allows developers to easily differentiate between device types, screen sizes, input methods, software capabilities and many more device properties.