Thursday, July 20, 2006

[WAP] Detecting Mobile devices on your WAP pages

The first thing you want to do while making a WAP site is to detect the browser that is accessing your site. Knowing the device that is accesing your site can help you determine what content and how this content should be delivered to the requesting browser.

I had been surfing through the web trying to determine the best way to go about detecting the users handset and carrier etc. but did not find a lot of material on this. I have included some of the stuff that works for me.

Determine the carrier:
The best way is to find this out is to look at the
HTTP_VIA header in the request. Most of the requests from handsets come through carrier gateways and that usually would provide you the name of the carrier.
e.g. One of the gateways for Sprint:
"1.1 kcindmagprx01-int.nmcc.sprintspectrum.com:8090, 1.1 ISA1"

As you can see, a simple search for "sprintspectrum" in the HTTP_VIA header will tell us that the mobile device is from Sprint. Similarly, Cingular devices have "mycingular" in the header.


Determine the handset:
There are 2 ways to go about this, you can either use the User Agent (HTTP_USER_AGENT) or the User Agent Profile (HTTP_PROFILE or HTTP_X_WAP_PROFILE). I prefer parsing the User Agent as it saves time making a request to get the RDF file and parsing the XML returned. However, if you need more information like the color depth, screen width and screen height then the UA profile is the way to go.

Some examples of User Agents are:

Nokia
- Nokia6230/2.0+(04.43)+Profile/MIDP-2.0+Configuration/CLDC-1.1+UP.Link/6.3.0.0.0
- NokiaN91-1/3.0 (1.00.001.15) SymbianOS/9.1 Series60/3.0 Profile/MIDP-2.0 Configuration/CLDC-1.1
-Mozilla/4.0 (compatible; MSIE 5.0; Series80/2.0 Nokia9500/4.51 Profile/MIDP-2.0 Configuration/CLDC-1.1

Sony Ericsson
- SonyEricssonK700i/R2N SEMC-Browser/4.0.1 Profile/MIDP-2.0 Configuration/CLDC-1.1

Motorola
-MOT-V3i/08.D8.35R MIB/2.2.1 Profile/MIDP-2.0 Configuration/CLDC-1.1
-Motorola-T33/1.5.1a UP.Browser/5.0.1.7.c.2 (GUI) (Google WAP Proxy/1.0)

Samsung
-SAMSUNG-SGH-T809/T809UVEJ9 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Browser/6.2.3.3.c.1.101 (GUI) MMP/2.0
-Samsung-SPHA680 AU-MIC-A680/2.0 MMP/2.0
-SEC-SGHD807/1.0 TSS/2.5 UP.Link/6.3.0.0.0
-SGH-Z500 SHP/VPP/R5 SMB3.1 SMM-MMS/1.2.0 profile/MIDP-2.0 configuration/CLDC-1.1 UP.Link/6.3.0.0.

Sanyo
-Mozilla/4.0 (MobilePhone MM-7500/US/1.0) NetFront/3.1 MMP/2.0

Audiovox
-AUDIOVOX-PM8910KIT/T115SP0T07 UP.Browser/6.2.2.6.h.1.100 (GUI) MMP/2.0

LG Electronics
-LGE-VI125V01/1.0 UP.Browser/6.2.3.2.1.1.100 (GUI) MMP/2.0
-LG-CU500 Obigo/WAP2.0 Profile/MIDP-2.0 Configuration/CLDC-1.1 UP.Link/6.3.0.0.0
-LG-LX350 AU-MIC-LX350/2.0 MMP/2.0 Profile/MIDP-2.0 Configuration/CLDC-1.1

Siemens BenQ
- SIE-ME45/05 UP.Browser/5.0.1.1.102 (GUI)

RIM
-BlackBerry7100/4.0.2 Profile/MIDP-2.0 Configuration/CLDC-1.1

HTC
-HTC-8100/1.2 Mozilla/4.0 (compatible; MSIE 5.5; Windows CE; PPC; 240x320)

Here is a good site where you can find a more comprehensive collection of User Agents.

As you can see, its pretty simple to extract the Model Name and Manufacturer name from the User Agent, but if you are looking for more information then the UA profile is the best way to go.

2 comments:

  1. Some changes coming to the IE mobile browser user agent. Read more here: http://blogs.msdn.com/iemobile/archive/2006/08/03/Detecting_IE_Mobile.aspx

    ReplyDelete
  2. LG Vx8000 from Verizon (CDMA)

    User Agent: LGE-VX8000/1.0 UP.Browser/6.2.3.1 (GUI) MMP/2.0

    The UA profile is present at
    http://uaprof.vtext.com/lg/vx8000/vx8000.xml

    ReplyDelete