Welcome!

Welcome to the Official BlackBerry Support Community Forums. This is your resource to discuss support topics with your peers, and learn from each other. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

BBM Social Platform – How to Create Profile Boxes

by BlackBerry Development Advisor on ‎07-25-2011 03:32 PM - edited on ‎07-25-2011 03:32 PM by BlackBerry Development Advisor

To see this code in action, download the attached archives which contain Java® and BlackBerry® WebWorks™ sample projects.

The BBM™ Social Platform offers the ability to place a custom Profile Box in the users profile in BBM.

                      

Before you begin: Make sure you visit the BBM Social Platform Development page and download the SDK in either Java or WebWorks.  Next, ensure that you’ve completed the task, Register your application with the BlackBerry Messenger, as described in the Development Guide.

 

Feature Overview

 

The profile box contains an image and a string and will appear under your application in the users profile screen:

 

profile.PNG 

 


The feature is enabled via the method calls below in either Java or WebWorks.  For a fully working sample application, download the attached project archive for either Java or WebWorks.


Java

UserProfile userProfile = platformContext.getUserProfile();

UserProfileBox profileBox = userProfile.getProfileBox();

if(profileBox.isAccessible()) // Ensure that we have permission to access the box

{               

       // Each icon used by your application must have a unique ID

int iconId = 1;

EncodedImage icon = EncodedImage.getEncodedImageResource("smiley.png");

profileBox.registerIcon(iconId, icon);

profileBox.addItem(iconId, "Always Happy!");

// A third parameter, cookie (String), can be added to give your app context when launched via the BBMPlatformContextListener listener.

 

}

WebWorks

<script type="text/javascript">

// Add an item with icon, text, and a cookie       

var iconID = { id:1, uri:"local:///profilebox/smiley.jpg"};

var options = {text:"Always Happy!", iconId:iconID};

blackberry.bbm.platform.self.profilebox.addItem(options);

</script>



As you can see, in both platforms, we get references to an icon and string and pass it to the addItem method of the ProfileBox class.  Note that in order for the boxes to appear, the user must give permission to your application to allow this behavior.

 

Contributors