developer sign in

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;
?>

Soft key limitations

Soft keys aren't accessible on the BlackBerry platform, but they do have Menu and Back buttons that you can map to. Below there's some sample code showing how to map Menu and Back buttons for BlackBerrys. This code also ensures that the 'back' key closes the menu when it is open.
<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>');
}
?>

Example

Click here to download a PHP sample putting it all together.

Questions?

The best way to understand BlackBerry limitations is to play with the emulator. If you run into any issues or have any questions, post it on the forum or shoot us a note.


trademarks | terms of use | privacy policy | about | FAQ | blog | jobs | contact us
For 24/7 support email support@where.com or call 888-262-1150
WHERE™ is a product from uLocate Communications, Inc. ©2008 All Rights Reserved.