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
New Contributor
orvn
Posts: 3
Registered: ‎05-27-2014
My Device: Z10
My Carrier: Wind
Accepted Solution

Blackberry Simulator User Agent is not Unique?

I'm having a lot of trouble customizing stylesheets for Blackberry devices because I don't have one in front of me, physically.

 

When I run the BlackberryOS simulator (using VMWare Fusion emulation on OSX 10.9) and run an inspector from a Webkit-based browser, I get this as the useragent:



navigator.userAgent
"Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.35 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.35"

Which doesn't seem like it would be the same string that a physical Blackberry device would output.. right? Below the the code (Javascript) I'm using to target Blackberry devices.

		   var ua = navigator.userAgent;
		   if (ua.match(/(BlackBerry|Blackberry|blackberry|BB|bb|RIM|rim|Playbook|PlayBook|playbook)/)!=null) { 
		   		document.write('');
		   		console.log ('Blackberry confirmed'); 
		   	}
Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 822
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Bell

Re: Blackberry Simulator User Agent is not Unique?

It looks like something weird is happening and the userAgent is coming from somewhere else. I'm not sure how.

 

The userAgent should be 

"Mozilla/5.0 (BB10; Touch) AppleWebKit/537.35+ (KHTML, like Gecko) Version/10.3.0.440 Mobile Safari/537.35+"

 

which I pulled from the 10.3 beta simulator.

 

If you need to match on the userAgent, add "BB10" to your list. I understand you are probably working on some software that can't be changed easily, but if at all possible I'd recommend moving to feature detection rather than browser detection. That's one of the reasons why the userAgent was changed with BB10 - it was because too many sites were detecting BlackBerry and giving users an experience tailored for phones from 7 or more years ago, when the currrent BB10 Browser is unmatched for it's performance and HTML5 capabilities.

Tim Windsor
Application Development Advisor II
Please use plain text.
New Contributor
orvn
Posts: 3
Registered: ‎05-27-2014
My Device: Z10
My Carrier: Wind

Re: Blackberry Simulator User Agent is not Unique?

Thanks! Do you know if there's a pure Javascript method of detecting Blackberries with feature detection? I'm not building an app with Webworks, just a responsive site (CSS) that the BlackBerry keyboard was throwing off the look of.

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 822
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Bell

Re: Blackberry Simulator User Agent is not Unique?

Not really - by feature detection I mean that you detect what APIs and features are available on a device, without caring what OS or hardware it is. I'm not sure it applies in the same way for the issue that you're tryign to resolve.

Tim Windsor
Application Development Advisor II
Please use plain text.
New Contributor
orvn
Posts: 3
Registered: ‎05-27-2014
My Device: Z10
My Carrier: Wind

Re: Blackberry Simulator User Agent is not Unique?

Thanks Tim,

 

I ended up buying a Z10 and a Q10 for testing. It's interesting, even without any device-specific adaptive design, the simulator doesn't always render layout in the same manner as physical devices.

 

The :1337 inspector is pretty awesome though, that helped me remedy the problem I was having.

Please use plain text.
BlackBerry Development Advisor
twindsor
Posts: 822
Registered: ‎07-15-2008
My Device: Z10
My Carrier: Bell

Re: Blackberry Simulator User Agent is not Unique?

Yeah, it's just not the same when you get down to the small details. WebInspector though, is an incredibly powerful tool. Glad to hear you've got it working.

Tim Windsor
Application Development Advisor II
Please use plain text.