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

Web and WebWorks Development

Reply
Highlighted
Contributor
Posts: 17
Registered: ‎01-30-2010
My Device: Bold 9900
My Carrier: Claro - Republica Dominicana
Accepted Solution

BBM && bbUI

Hi, so here's my new issue (yes another one Smiley Sad) at the prompt to register with BBM, if the user allows it, I need the app to add new menu items to the menu (invite to download and chat with contact in bbm) and if the user cancels the registration need to add a register with BBM menu item to the menu, but once either of these events occur I'm stock with the menu's items I already have, it's not adding the new ones.

I've tried using the ondomready and onscreenready events to no avail (prolly not doing it right). The call to register with bbm javascript is in the head element of my index file and it's call when the app loads for the first time

<body onload="registerWithBBM();bb.pushScreen('menu.html', 'menu');">

 Is on this menu.html screen that I need the new menu items added once it loads, but by the time I'm prompted to register the screen is already loaded and the changes don't take effect.

 

 

function registerWithBBM () {
	// Create callback invoked when access changes
blackberry.bbm.platform.onaccesschanged = function(accessible, status) {
    if (status == "allowed") {
        // Access allowed
        var menuItem = document.getElementById("bbm-menu");
        menuItem.innerHTML += '<div data-bb-type="menu-item" onclick="chatInBBM();">Chat with Contact</div>'
        menuItem.innerHTML += '<div data-bb-type="menu-item" onclick="inviteToDownload();">Invite to Download</div>'
    } else if (status == "user") {
        // Access blocked by user
        menuItem.innerHTML += '<div data-bb-type="menu-item" onclick="showBBMAppOptionsAndRegister();">Connect to BBM</div>'
}};

or

 

blackberry.bbm.platform.onaccesschanged = function(accessible, status) {
    if (status == "allowed") {
dataOnTheFly_initialLoad(element);
}

 where dataOnTheFly = 

function dataOnTheFly_initialLoad(element) {
	var menuItem, lista = element.getElementById('bbm-menu');
	menuItem = document.createElement('div');
	menuItem.setAttribute('data-bb-type', 'menu-item');
	menuItem.innerHTML = 'Invita a Descargar';
	lista.appendChild(menuItem);
}

 Placing the register w/ BBM JS file on the menu.html screen throws an uncaught exception

Developer
Posts: 214
Registered: ‎01-07-2011
My Device: Bold 9900
My Carrier: Rogers

Re: BBM && bbUI

Currently adding items dynamically to the menu in this way is not supported in bbUI.js. If you want to do it specifically on on a SmartPhone just use the API calls once you know if BBM is allowed or not. Just make sure not to use clearMenuItems like they do in the example code Smiley Happy This is actually what bbUI is doing on the phones when it does the initial setup.

 

https://bdsc.webapps.blackberry.com/html5/apis/blackberry.ui.menu.html#.addMenuItem

 

There has been discussion about doing this for the Playbook as well, but it is still a work in progress.

--
Rory (@roryboy)
Click "Accept as Solution" if post solved your original issue. Give like/thumbs up if you feel post is helpful
Contributor
Posts: 17
Registered: ‎01-30-2010
My Device: Bold 9900
My Carrier: Claro - Republica Dominicana

Re: BBM && bbUI

Rory thanks for your quick reply I'll give this a try and post back

thank you as always Smiley Wink Hope you're having a great time at bbwc

Contributor
Posts: 21
Registered: ‎05-04-2012
My Device: Dev Alpha B & C, Z10 and PlayBook
My Carrier: Vodafone Spain

Re: BBM && bbUI

Hi larturo, I see a mistake in your function registerWithBBM, if status is allowed you defined menuItem (with the DOM element bbm-menu), but if the status is user you don't define it. I think ttaht you must define the var menuItem before the if else stament.

 

Saludos Smiley Wink

Contributor
Posts: 17
Registered: ‎01-30-2010
My Device: Bold 9900
My Carrier: Claro - Republica Dominicana

Re: BBM && bbUI

Fotodng I see your point and appreciate the observation thank you very much but since I'm going with Rory's suggestion I'm changing most of this. Gracias de todas formas. ;-)
Contributor
Posts: 21
Registered: ‎05-04-2012
My Device: Dev Alpha B & C, Z10 and PlayBook
My Carrier: Vodafone Spain

Re: BBM && bbUI

Ok, gracias larturo.