Working with the user profile

The BBM Social Platform provides both read and write access to a user’s BlackBerry Messenger profile. Your app can access their personal message, display name, status message, and display picture.

You can update the user's BBM profile by using the set functions in the bbmsp_userprofile API. A dialog displays to allow the user to accept or reject the change.

When a user or a contact makes a change to their BBM profile you can determine what was changed by retrieving the update type associated with the event that is triggered when the change is made. Use the event category and type to determine whether the change applies to a user or to a contact. Call bbmsp_event_profile_changed_get_presence_update_type() or bbmsp_event_contact_changed_get_presence_update_type() to retrieve the update type for a user or contact, respectively.

The following table summarizes the event categories and update types that relate to profile changes.

Event Update types
User profile:
  • category = BBMSP_USER_PROFILE
Contact list:
  • category = BBMSP_CONTACT_LIST







Reading and writing to the BBM user profile

The following code samples show you how to read from and write to a user's BlackBerry Messenger profile. To access the user profile, you'll need to include the following classes in your app's header file.

#include "bbmsp/bbmsp_userprofile.h"
#include <bbmsp/bbmsp_presence.h>

Read a user's BBM profile

This code sample demonstrates how to read a user's BBM profile by retrieving their display name.

Begin by creating and initializing an empty profile object (m_profile), and then populating it with the user's BBM profile data.

// Initializes a pointer to the profile object
  bbmsp_profile_t *m_profile = 0;

// Creates the new, empty profile object

// Populates the object with the user's profile data

Next, define a function called read_profile_display_name() and pass in the user's profile data. Because you don't know the length of the user's display name, create an array (displayName) using the maximum allowed length to hold the string. Then call bbmsp_profile_get_display_name() and pass in the profile object, the array, and the array size. If the display name field is not empty, the string is returned in displayName and you print it out. Otherwise, print out an error message.

void read_profile_display_name(bbmsp_profile_t *m_profile)
    // Creates an array to hold the display name
    // Retrieves the display name, prompts the user to accept/reject,
    // and displays a message accordingly
    if(BBMSP_FAILURE == bbmsp_profile_get_display_name(m_profile, 
      displayName[0] = 0;
      fprintf(stdout, "Error: Failed to get Display Name.\n");
    fprintf(stdout, "BBMSP display name=%s\n", displayName);

Write to a user's BBM profile

Because BBM doesn't allow you to change a user's display name, the following code sample demonstrates how to write to a user's BBM profile by changing their personal message.

First, you define a function, write_profile_personal_message(). Then create an array (message) that contains the new message and pass it in to bbmsp_set_user_profile_personal_message(). The function displays a dialog box that shows the new personal message and prompts the user to accept or reject the change.

Screen showing the profile update confirmation dialog.

If the user accepts the change, bbmsp_set_user_profile_personal_message() writes the new message to the user's profile. Otherwise you print out a failure message.

Screen showing the updated user profile.
void write_profile_personal_message()
  // Creates an array with the new personal message
  char message[46] = "Updated by the BBMSP bps User Profile sample!";
  // Sets the personal message, prompts the user to accept/reject,
  // and displays a message accordingly
  if (BBMSP_FAILURE == bbmsp_set_user_profile_personal_message(message))
    fprintf(stdout, "Failed to update personal message.\n");
  } else
    fprintf(stdout, "Updated BBM SP personal message to:%s.\n",

You can download the complete sample app from the Core Native Community on GitHub.

Last modified: 2014-05-14

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus