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.

inside custom component

Native Development

Reply
Trusted Contributor
sucroid
Posts: 195
Registered: ‎03-12-2012
My Device: PlayBook

bbmsp_register doesn't work

http://developer.blackberry.com/native/beta/reference/com.qnx.doc.bbmsp.lib_ref/topic/overview.html

 

I tried the code above with a number of UUIDs generated by http://www.guidgenerator.com/online-guid-generator.aspx

 

Every time bbmsp_register failed.  What am I missing?

Sucroid.com
Sweet Apps for the Fans
Contributor
agryc
Posts: 12
Registered: ‎08-30-2013
My Device: Z10

Re: bbmsp_register doesn't work

Hi sucroid,

Did you ever get this problem resolved, and if so, what was the cause? I'm encountering the same issue; bbmsp_register fails, and I can't figure out why (error return doesn't give any data).

 

I saw on some other thread a note about needing a window group created to allow the bbm framework to operate, and as my app is all hand-crafted OpenGL ES (not Qt), I'm going to investigate. I was hoping you might share what (if ever) you did to get past this.

Contributor
agryc
Posts: 12
Registered: ‎08-30-2013
My Device: Z10

Re: bbmsp_register doesn't work

In case anyone else experiences this problem, the window group was definitely part of the issue. Without a window group, bbmsp_register would return a failure (-1) and my event loop would never get any BBM events matching bbmsp_get_domain. With a window group now, I still get a failure returned, but I at least now I'm getting a BBM event of BBMSP_SP_EVENT_ACCESS_CHANGED.

 

Now the subsequent call to bbmsp_event_access_changed_get_access_allowed returns failure, so something is still wrong, but it's at least one step closer to working. (Once I figure that part out, I'll post it too.)

 

Here's the simple code I added after my screen_create_window call:

 

rc = screen_create_window_group(screen_win, get_window_group_id());
if (rc) {
        perror("screen_create_window_group");
        bbutil_terminate();
        return EXIT_FAILURE;
}

 

 

 

And I added this function (stolen shamelessly from the PlayBook examples) to create a unique group id:

 

/**
 * Use the PID to set the window group id.
 */
static char *
get_window_group_id()
{
    static char s_window_group_id[16] = "";
    if (s_window_group_id[0] == '\0') {
        snprintf(s_window_group_id, sizeof(s_window_group_id), "%d", getpid());
    }
    return s_window_group_id;
}

 

Contributor
agryc
Posts: 12
Registered: ‎08-30-2013
My Device: Z10

Re: bbmsp_register doesn't work

Getting a little further. Part two of the problem is that some of the samples provided for adding BBM support are not correct. For example, this snippet of code (can't remember which sample I took it from originally) is wrong.

 

bbmsp_result_t rc = BBMSP_SUCCESS;

rc = bbmsp_request_events(0); // 0=request all events
if (rc != BBMSP_SUCCESS) {
 	return;
}

// //NOTE: BELOW CALL WILL ALWAYS FAIL!!!
// bbmsp_result_t rc = bbmsp_register(UUID); if (rc == BBMSP_FAILURE) { LOG("BBM unregistered %d\n", bbmsp_get_access_code()); }

 

It fails because the register function must be called after a certain amount of asynchronous work has been done by the bbm functions. Calling it immediately doesn't give the system enough time to register.

 

The proper way to do this appears to be from within the event handler. Here's a sample that appears to work properly and uses the right sequencing:

 

https://github.com/blackberry/Core-Native-Community-Samples/tree/master/BBMbpsUserProfile

 

After reordering how I register BBM to match the code sample above, BBM functions all seem to be working and returning success codes.

 

However, when I invoke the function I really want  bbmsp_send_download_invitation(), it seems to grey my application window (so it's clearly doing something), but I don't see any dialog appear. If I touch the screen everywhere randomly, eventually the screen ungreys going back to normal (as if I'm dismissing an invisible dialog). I'm guessing I need to be handling some other type of events that I'm not right now. This is a raw OpenGL ES app, not a Qt app, so I'm sure I'm not dispatching something the BBM dialog cares about. Once I figure that out, I'll post here.

BlackBerry Development Advisor
MSohm
Posts: 14,757
Registered: ‎07-09-2008
My Device: BlackBerry Passport

Re: bbmsp_register doesn't work

You'll need to ensure that your application contains a window group before calling bbmsp_send_download_invitation, which is required for the invite to download card to be shown within your application.

Mark Sohm
BlackBerry Development Advisor

Please refrain from posting new questions in solved threads.
Problem solved? Click the Accept As Solution button.
Found a bug? Report it using Issue Tracker
Contributor
agryc
Posts: 12
Registered: ‎08-30-2013
My Device: Z10

Re: bbmsp_register doesn't work

Thanks--my last response actually *did* work. I'm not sure problem I was experiencing with the grey invisible dialog, but after changing something about the environment (not any of the code--either closing Eclipse or rebooting phone) it is now working just fine. Thanks for following up.