Make your App Social with BBM

This is @leaschnherr, a student working in the Tech Center Bochum with @Klajili. Happy to show you today how to register your app to BBM in a very simple way. This will help your app getting viral and increase the downloads considerably.

Screen Shot 2013-10-31 at 5.05.45 PM

First thing you need to do is to set the permission for BlackBerry Messenger in your app bar-descriptor.xml file. If you use momentics, you can double click on it and go to the Application tab to see and set the permission.

Second you will need to add the BBM platform libraries to your project by adding the line LIBS += -lbbplatformbbm in the .pro file or rigth click on your Project->Configure->Add Library… . Choose Standard BlackBerry platform library, click next an search for “libbbplatformbbm”. Select this library an click finish. This will modifiy your .pri file.

To use BBM you need an UUID. This is needed to identify your app to BBM. You can for example get one at: Every app needs its own unique UUID and you should use the same UUID when you release a new version of your app.

Let’s modify main.cpp first:

As you can see, just few lines of code are required. Besides the UUID you can show a GUI to indicate the user what is happening. Now only three other lines are needed. The creation of the Registration class and Profile class (This class will be filled later to show the profile). The third line connects the signal of the Registration class (which is emitted when registration is ready) and the slot which shows the next page.

The class Registration registers the app to BBM. This step is only required when you start the app for the first time. So the first part of the code is to check in which state the app is. For this the class Context and its property RegistrationState is used. RegistrationState concludes an enum with 15 possible states of your app (The possible states are documented here). In your code you have to check the current state of your app and possibly, according to your state, request to register your app. Here it is done by a method with a switch case instruction, but does not considering all possible states. Instead a qDebug output is used, to follow the registration process and see, in case, what went wrong.

Because the state could switch several times you have to connect registrationStatus() as slot  with the signal registerStateUpdated() from the Context class.

To kick off registration registrationStatus() has to be called at least one time. Either the app is now request to register or a signal emits to indicate, that the app is already registered. The third option is that an error is occurred. In this case read the state in your console to fix the error. When everything went right, BBM shows a Toast .


This Toast appears automatically after registration

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">