Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Developer
amsiddh
Posts: 142
Registered: ‎06-26-2009
My Device: Not Specified

How to Detect Device by Browser ?

Hi,

I am building a website optimized for mobile devices. When i hit the url of the site i perform a check on the User Agent

( like Blackberry9000/4.6.0.247 Profile/MIDP-2.0 Configuration/CLDC-1.1 VendorID/247 )

to detect if the browser is the Blackberry browser of the device and accordingly redirect it to the mobile version of the site.

 

However, if i hit the url using the IE & Firefox browsers by setting the Browser Configuration to IE / Firefox on Blackberry Device the user agent returned is that of the Browsers(IE & Firefox) wherein i cannot by any means identify whether the browser is the Blackberry device browser or a normal PC IE/Firefox browser and as a result redirection takes the user to the PC version of the site.

 

My urgent requirement is to detect all url hits from Blackberry device no matter what the browser used i.e. to make sure that the browser hitting the url is from a blackberry device.

Please post any solutions or methods that i could use.

Developer
pwoods
Posts: 20
Registered: ‎04-01-2008
My Device: Not Specified

Re: How to Detect Device by Browser ?

you'll see that the blackberry also introducesa $_SERVER['profile'] variable which is a URL to a XML file that gives you all the details about the blackberry device the user is using.  Including the screen size and resolutions.  So I'd use that instead.

 

Just do a 

 

var_dump($_SERVER);

 

and you'll see waht I mean.

Developer
pwoods
Posts: 20
Registered: ‎04-01-2008
My Device: Not Specified

Re: How to Detect Device by Browser ?