Blackberry Messenger User Manual Page 5

  • Download
  • Add to my manuals
  • Print
  • Page
    / 11
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 4
http://cmer.uoguelph.ca 5
The last step that will need to be added in the setupApplications function is to clear the
profile box of any old entries from the last time the user had the application open. To do
this, simply add the following line as the last statement in the function:
blackberry.bbm.platform.self.profilebox.clearItems();
Regularly in order to call these functions, we’ll need to add the features to the application
using the config.xml file which must be included in all WebWorks applications. If you
open the file included in the lab, you will see the line <feature
id="blackberry.bbm.platform" required="true " version="1.0.0.0"/>.
This line means that our application can access the BBM platform SDK and all functions
within it.
In order for us to do anything with BBM, we also need to register the application with the
platform. Create a function called registerApplication which will be responsible for
registering the application with the BBM platform. Before we register the application,
we’ll need to add some callback functions to handle events which can occur.
The first callback function we will add handles events when the applications access
changes. In the registerApplication function, add the following callback function
/**
* Required
* This is called when the application's access to BBM platform changes.
*/
blackberry.bbm.platform.onaccesschanged = function (accessible, status)
{
// If allowed, initialize the application
if (status === "allowed")
{
var startDiv = document.getElementById("start");
startDiv.innerHTML = "<center><h5>Connected to BBM</h5></center>";
// If not allowed, show error
}
else
{
alert("Failed to connect to BBM: "+getStatusMessage(status));
/*
* If blocked by the user, add a button to prompt the user to
reconnect to BBM.
*/
if (status === "user")
{
var startDiv = document.getElementById("start");
startDiv.innerHTML = "<center><h5><button
onclick='showBBMAppOptionsAndRegister()'>Connect to
BBM</button></h5></center>";
}
else
{
var startDiv = document.getElementById("start");
startDiv.innerHTML = "<center><h5>Connect to BBM
failed</h5></center>";
}
}
};
This callback function will alert the user once they are connected to BBM by changing
the text in the ‘start’ div on the HTML page. Likewise, if the connection fails, the user
will be presented with a button which reconnects to BBM. We’ll define the function
Page view 4
1 2 3 4 5 6 7 8 9 10 11

Comments to this Manuals

No comments