Device Detection with WURFL

This tutorial will introduce you to WURFL and demonstrate how it can be used for device detection and cross-platform mobile web development.


What is WURFL?

WURFL is a Device Description Repository (DDR) which serves as a central source of device information for mobile web applications. It contains descriptions of thousands of mobile devices that can be used in any application, free or commercial

ScientiaMobile is the company behind the project, which stands for Wireless Universal Resource File. WURFL is recognized as the de-facto standard in the area of Device Description Repositories. The project began in 2002, with the intention of tackling the issues of mobile device fragmentation. It seeks to do so by providing developers across the world with a common set of device information.

WURFL has the following editions:

  1. Java Edition
  2. PHP Edition
  3. .Net Edition (Also called NuGet)
  4. Database Edition

WURFL is available as an open source project and also with commercial licenses. The free version is generally used by open-source projects, whereas websites belonging to licensee organizations go for commercial version.


Wireless Abstraction Library (WALL)

WALL (Wireless Abstraction Library) is a JSP tag library that lets a developer author mobile pages similar to plain HTML, while delivering WML, C-HTML or a XHTML Mobile Profile to the device from which the HTTP request originates. The proper format is chosen depending on the actual capabilities of the device sending the request.

WALL Markup

The figure on the left shows the different markup languages. Since the coders design the application to support all the available devices, the available domain for coding is the area of intersection. Due to introduction of more and more devices and the difference in device support and features, this region generally becomes smaller and smaller.

WURFL addresses this issue by detecting the device type and then delivering suitable markup. The figure on right demonstrates the available markup range for the coders to develop, which is the sum of all the markup regions.

WURFL contains 7,000+ unique devices and thousands of firmware variations, representing nearly every mobile device on the market worldwide!


WURFL Flow

Once an application request from a device reaches the web server, the WURFL framework detects the device type and produces markup generated specifically for the device. The diagram below shows the request flow for web applications having WURFL integration enabled:

WURFL Project Flow

WURFL Structure

The configuration files for WURFL are written in XML and consist of a list of devices with their capabilties. WURFL.mxl has a list of all the devices available, along with the features embedded within the file itself. Other files vary with different versions of WURFL.

WURFL Structure

The diagram above represents the WURFL structure for the Java version. The configuration file sits on the root folder of the web servers where the application resides. Therefore, all the pages in the web server can make use of WURFL easily.

To start working with WURFL, you need to download the configuration file from the WURFL site. This configuration file needs to be hosted directly inside the root folder of the web server (as shown in the diagram above).


Groups & Capabilities

A Group in WURFL is a set of similar features clubbed together. For example, a group could include Markup, Image Format, Sound Format, Display, Ajax Support, Cache Support, CSS, SMS, MMS, etc. for a particular subset of devices.

A Capability is a unique feature that defines an individual functionality supported by a mobile device


WURFL Functionality

The sample code below is from the WURFL repository file (WURFL.xml), which contains groups and capabilities for a device:

This is the configuration file which is queried for device information. So, if a new device is introduced into the market, we need to add the information in this file.

The functionality of WURFL can be explained in two steps :

  1. Device detection : When a request from a device comes in, the WURFL repository file is queried for the USER_AGENT value. This is a unique value for each device.
  2. Return capability Value : Once the USER_AGENT is obtained, the repository is queried again and corresponding groups and capabilities are obtained. Then the markup is created for the requesting device that corresponds to the capability values. If the capabilities are not found within the id for USER_AGENT, the capabilities are obtained following the inheritance using the id from the FALL_BACK value. The inheritance chain continues till the capability values are available for markup.

Including WURFL

WURFL can be included in various formats like PHP, JSP and .NET.

The example below shows how we include a WURFL repository to a JSP page.

A WURFL enabled page must include two files:

  • /WEB-INF/tld/wall.tld: This tag library descriptor page is included at the top of the page.
  • /WEB-INF/tld/c.tld: This page is included just above the body tag

The example below demonstrates how WURFL works and shows how a WURFL enabled JSP page hosted in the web server might like look:

In this example, if the page is requested by a web browser whose resolution width is more than 700, the first part of the condition will be executed and pageA.html would appear on the iframe. Otherwise, pageB.html would appear.

Similarly, we can make use of capabilities to query the device properties and provide markups, display styles, images, and and also manipulate content based on device type.


Who is Using WURFL?

Currently, a large number of companies are using WURFL for development of mobile websites. These include companies who are large and medium content providers, but the most popular usage of WURFL is in companies that are small content providers. Some of the most popular companies that make use of WURFL are Vodafone, Mobile Galleries, and Pepsi UK.

Tags:

Comments

Related Articles