views:

6027

answers:

14

We are beginning to go down the path of mobile browser support for an enterprise e-commerce webapp (Java/Servlet based). Of course there are many decisions to be made, but it seems to me the cornerstone is to be able to reliably detect mobile browsers, and make decisions on the content to be returned accordingly. Is there a standard way to make this determination (quickly) based on the http request, and ideally glean more information about the given browser and device making the request (screen size, html capabilities, etc?).

I would also appreciate any supplemental information that would be of use from someone who has gone down this path of taking an existing large scale enterprise webapp and architect-ing out mobile browser support from the development side.

[edit] I certainly understand the request header and the information about a database of standard user agents is a great help. For those talking about 'other' request header properties, if you could include similar standardized name / resource of values that would be a big help.

[edit] Several users have proposed solutions that involve a call over the wire to some web service that will do the detection. While I'm sure this works, it is not a good solution for an enterprise e-commerce site for two reasons: 1) speed. A call over the wire for every page request to a third party would have huge performance implications. 2) dependency/legal. We'd tie our website response time and key functionality to their service, which is horrible for legal and risk reasons.

+24  A: 

Wouldn't the standard way be to check the user agent? Here's a database of user agents you can use to detect mobile browsers.

David
I didn't realize there was an actively maintained reference for these. Thanks.
Pete
A: 

You will have to check the user agent string with a previously defined list, like this one

hayalci
+4  A: 

This article (and its follow-up) seems nice.

Milen A. Radev
+1  A: 

You will get most of the information like browser, device, accepted languages, accepted formats etc from the request header. The user agent mentioned above is part of the request header.

Vijesh VP
+5  A: 

While you could detect a mobile browser through it's user agent the browser war on the PC platform has shown that sniffing user agents isn't really such a good thing to do.

What ideally should be done is that specific styles should be applied based on media type or that a different answer should be sent based on a header other than the user agent - such as the Accept-header which tells which kind of content that the browser prefers.

Right now it might be enough to code a site that works with the iPhone and with Opera through browser sniffing - but Googles Anroid is coming any minute now and there are many other mobile phones that will have browser functionality close to the iPhone's in the near future and it would be a waste to develop a mobile website that didn't support those devices as good as possibel from scratch.

VoxPelli
+10  A: 

David mentioned using WURFL -- which is probably your best option. Be forewarned, however, the success rate is usually around 60% (from mine and other's experience). With carriers changing UA's constantly and the amount of device profiles that exist (60,000+ ?), there's no bulletproof way to get all the right data you want.

Just a bit of warning before relying heavily on a device DB. I try to keep the user's options open by allowing them to change session options in case i've guessed wrong.

jmccartie
A: 

you can use a webservice to detect mobile browsing like handsetdetection.com.

A call over the wire for each page request is not feasible for performance reasons
Pete
+2  A: 

I propose a free detection system which is based on uaprof and user agent: http://www.mobilemultimedia.be UAprof should be the primary key for detection when it's available as there are usually multiple user agents for the same uaprof. If you want to manage this on your own, you should then go for Wurfl because you can download the entire database and manage it locally by yourself.

A: 

The fact is that just relying on the useragent is not good enough to detect mobile browsers.

Sure, years ago you could search it for certain strings and guess that it was a Nokia or something, but now there are so many phones out there, and so many that pretend to be things that they are not that something more sophisticated is needed.

I found a great site at link textwhich is based on the same solution that MTV use for all their mobile web sites. It is REALLY good as it has a device independent markup language but more importantly they offer a webservice call for isMobileDevice().

Just look in the manual then 'how it works'.

I've been using it for my customers sites and have yet to find a mobile browser that it doesn't detect accurately. Totally blinding!

This is not reasonable for performance reasons - 'Using WAPL is extremely easy and only requires that you pass valid WAPL to Wapple's servers using the SOAP or REST webservices. The webservice server responds with the markup for you to output to the device. You have complete control over content, design and presentational elements.'
Pete
It is probably relevant to point out that the answerer is the CTO of the organisation "wapple" that publish wapl.info and other related service provided by wapple. http://www.gomonews.com/richwapple/
Cheekysoft
A: 

Hello

Please look at http://51degrees.codeplex.com/ It is a open source .NET mobile API with lots of features

1) Easily detects that request is coming from mobile device and redirects user to mobile landing page defined in web.config file. You do not have to write any code in page load event for this. It makes use of WURLF (most trusted mobile device information database) for detection of request coming from mobile device.

2) Gives detailed information about mobile device capabilities. Using this you can customize pages as per the capabilities supported by mobile device.

3) It also provides free mobile controls like google maps, location, image, calendar etc.. You can integrate this features very easily in your website by just writing simple tags.

4) Many more features.

I have found this very useful and easy to implement.

Thanks

Amit Patel
+1  A: 

When I had a similar need recently, I found this code that uses HTTP_X_WAP_PROFILE, HTTP_ACCEPT, and HTTP_USER_AGENT to identify a browser as mobile or non-mobile. It's PHP but could be converted fairly easily into whatever you need (I implemented it in VBScript for classic ASP).

Ironically, it turned out that I didn't end up using the code because we decided to provide specific URLs for mobile and non-mobile users, but it certainly worked when I was testing it ...

Dave DuPlantis
+1  A: 

After days of searching for the right way of detecting a mobile device I've decided to keep it simple [ stupid ] and i shall put a 'Mobile device site' button on my index page.... it's only one click away!!

Paul
+2  A: 

You can use Modernizer to detect browser abilities

Adam
A: 

Just ran across Device and feature detection on the mobile web with these contents:

  1. Using device and feature detection to improve user experience on the mobile web
  2. Introduction to device detection
  3. Approaches to mobile site design
    1. Do nothing
    2. Providing a generic mobile site
    3. Designing with mobile and adaptation in mind
  4. Content adaptation and device grouping strategies
    1. Device grouping
    2. Content adaptation
  5. Minimising the need for adaptation in the first place
  6. Common approaches to device detection
    1. Server side adaptation
    2. Client-side adaptation
    3. Server-side User Agent (UA) and header lookup
    4. Server-side UA string combined with device database lookup
    5. Server-side User Agent Profiles (UAProf) detection
    6. Detection based on JavaScript technology
    7. CSS media types
    8. CSS media queries
  7. Additional best practices
    1. Redirection + manual link
    2. Landing page + manual link
  8. Downloadable sample page
Kevin Hakanson