
http://cmer.uoguelph.ca 6
showBBMAppOptionsAndRegister next which will prompt the user to reconnect the
application to BBM after we finish with the registerApplication function.
The next step that is required in the registerApplication function is to actually register the
application. We can do this by adding the following lines of code to the end of the
registerApplication function:
//Register the application
try {
blackberry.bbm.platform.register({
// TODO You must define your own UUID
uuid: "uuid"
});
} catch (e) {
alert("You must define your own UUID.");
}
You’ll notice that we have a UUID field when we register. A UUID is basically a unique
identifier for the application. You’ll need to generate you own UUID to register the
application. An online UUID generator can be found here:
http://www.guidgenerator.com/online-guid-generator.aspx
Once generated, your UUID string should look something like: uuid: "707968e9-
ae6d-4dbb-b0f5-058a08df8275".
Finally, add a call to the registerApplication function in the setupApplication function
after the call to the setupMenuItems function. The reason we do not place the call to
register at the end of the function is because our application needs to be registered before
we call any BBM API related functions, such as
blackberry.bbm.platform.self.profilebox.clearItems(); which is at the end
of the setupApplication function.
Now let’s add the function to reconnect to BBM in case the connection fails for any
reason. You may remember we said the function would be called
showBBMAppOptionsAndRegister. Let’s create it now. Add the following function to
your JavaScript code.
function showBBMAppOptionsAndRegister()
{
blackberry.bbm.platform.showBBMAppOptions(function ()
{
registerApplication();
});
}
This function will show a window allowing the user edit the BBM options for the
application. After the window closes, the registerApplication function will be called.
Another function we’ll need to add is the getStatusMessage function. If an error occurs,
there is an associated reason. This function will change the error code into a reason the
user can understand.
Kommentare zu diesen Handbüchern