Detecting Mobile Device Cabalities
Some web applications require interaction with mobile devices. A key ingredient when writing such application for mobile devices is figuring out which device "talks" with our server, serve it with best fit markup, and make correct business-logic decisions (i.e. send the correct video format, setup package, etc.)
There are several tools that help us to cope with these challenges, all of them are built on top of a database (mostly XML files) which contains a mapping between devices and User Agents.
A very well known library that helps to detect device capabilities is WURFL - an open source project. The XML that contains devices data is maintained by the community. WURFL project has started in Java, but today it has libraries for .NET, PHP, Perl, Ruby, and Python (hope I did not forget anyone). As in many community based frameworks, several very nice satellite projects / utilities exists. Some of them can be found here.
In ASP.NET there are several built in mechanisms that help us to deal with different device capabilities, such as screen size, colors, image support, sound support, and many more.
All these mechanism are based on the fact that the server can "tell" which device is accessing the web application. The basic mechanism is Browser Definition File Schema, which allows saving browser information in files, and makes ASP.NET to tell which browser issued the HTTP request. Accessing this information is easier than using a 3rd party library, because of the simple fact that all data is accessible through the standard Request object - directly: Request.ScreenPixelsHeight, or via the Browser property: Request.Browser["CapabilityName"], without the need to program anything (or even without referencing external libraries). But where do we get all device information? - Mapping all these devices can take ages!
Well, a project called Mobile Device Browser File - MDBF comes to the rescue. It is hosted in Code Plex, and contains a .browser file with many many devices. It is maintained by MS Hotmail team members, and based on their experience serving devices which are used to access their service.
To summarize, there are two major options you can use for getting device information and capabilities:
Minor, but still:
- Needs a setup.
- Client needs More lines of code (comparing with MDBF).