Developing for BlackBerry
WHERE recently launched on BlackBerry, and you'll need to make some modifications to your widget to have it display properly on BlackBerry devices.
Testing on an emulator
Sign up for the BlackBerry developer program and download the v4.2.1 BlackBerry Pearl 8100 simulator.Download our Where BlackBerry .COD File and load it in the emulator (File -> Load Java Program).
In the emulator, go to Applications and select the Where icon -- Now you can login with your developer account and access all your widgets.
Recognizing a BlackBerry device
To check if the device the user registered with is a BlackBerry, check against the User Agent device. Here's php code that does just that:
<?php
$userAgentArray = (explode("/", $_SERVER['HTTP_USER_AGENT'], 2));
$device = $userAgentArray[0];
$isblackberry = stristr($device, "blackberry");
if ($isblackberry === false)
$isblackberry = false;
else
$isblackberry = true;
?>
$userAgentArray = (explode("/", $_SERVER['HTTP_USER_AGENT'], 2));
$device = $userAgentArray[0];
$isblackberry = stristr($device, "blackberry");
if ($isblackberry === false)
$isblackberry = false;
else
$isblackberry = true;
?>
Soft key limitations

<script>
<?php
if ($isblackberry)
{
?>
addTrigger("menu", checkShowPopup(), "back", checkHidePopup());
<?php
}
?>
function checkShowPopup() {
if (isPopupVisible()){
hidePopup();
}
else{ showPopup(); }
}
function checkHidePopup(){
if (isPopupVisible()) {
hidePopup();
}
else { back(); }
}
</script>
<?php
if ($isblackberry)
{
?>
addTrigger("menu", checkShowPopup(), "back", checkHidePopup());
<?php
}
?>
function checkShowPopup() {
if (isPopupVisible()){
hidePopup();
}
else{ showPopup(); }
}
function checkHidePopup(){
if (isPopupVisible()) {
hidePopup();
}
else { back(); }
}
</script>
Since functions that are normally mapped to soft keys rightCmd and leftCmd aren't available, if you have any functions that you map to these keys other than Menu and Back, you should add them to the menu popup or display them as buttons on the page when a BlackBerry device is detected.
Additionally, there shouldn't be any buttons in the footer when a BlackBerry device is detected, because there are no right and left soft keys to map them to.
Here's some sample php code that displays a generic blank Where footer if the phone is a BlackBerry, otherwise it uses Menu and Back options in the footer.
<?php
$width = (isset($_GET['screenwidth'])) ? $_GET['screenwidth'] : 240;
if($isblackberry)
{
echo('<footer bgImg="http://www.where.com/images/dd/mobile/'.$width.'/where_banner.png" />');
}
else
{
echo('<footer>');
echo('<img id="rightCmd" src="http://www.where.com/images/dd/mobile/'.$width.'/widget.png" onSelect="checkShowPopup()"/>');
echo('<img id="leftCmd" src="http://www.where.com/images/dd/mobile/'.$width.'/back.png" onSelect="checkHidePopup()"/>');
echo('</footer>');
}
?>
$width = (isset($_GET['screenwidth'])) ? $_GET['screenwidth'] : 240;
if($isblackberry)
{
echo('<footer bgImg="http://www.where.com/images/dd/mobile/'.$width.'/where_banner.png" />');
}
else
{
echo('<footer>');
echo('<img id="rightCmd" src="http://www.where.com/images/dd/mobile/'.$width.'/widget.png" onSelect="checkShowPopup()"/>');
echo('<img id="leftCmd" src="http://www.where.com/images/dd/mobile/'.$width.'/back.png" onSelect="checkHidePopup()"/>');
echo('</footer>');
}
?>