Simple BBM Integration in WebWorks Featured

Jeremy wrote up a great article about integrating BBM into Cascades, and a few people mentioned they wanted to see an article about getting BBM integrated with WebWorks. I've been kind of off the radar lately, but figured this was a good topic for me to do a quick writeup on.

Now, to contnue with some friendly teasing I directed at Jeremy eariler: integrating BBM into Cascades may be easy, but integrating it into WebWorks makes integrating it into Cascades look like rocket science. Yes, it really is that easy.

If you want to follow along, about 8 months ago I wrote up a BBM Integration Sample that I'll be using in this article. You can find it at https://github.com/SCrid2000/SCrApps-WebWorks-BB10-Apps/tree/master/KISSBBM.

1First, make sure you get your config set up right. For BBM integration, you need two additions:

<feature id="blackberry.bbm.platform" />
<rim:permissions>
     <rim:permit>bbm_connect</rim:permit>
</rim:permissions>

2Now that your config.xml is set up, you need to add some JavaScript to register your app with the BBM Server. To do that, you use the following function:

document.addEventListener('DOMContentLoaded', function() {
	blackberry.event.addEventListener('onaccesschanged', function (accessible, status) {
		if (status === 'unregistered') {
			blackberry.bbm.platform.register({
				uuid: '33490f91-ad95-4ba9-82c4-33f6ad69fbbc'
			});
		} else if (status === 'allowed') {
			bbm.registered = accessible;
		}
	}, false)
})

I personally use http://www.uuidgenerator.net/ to get a UUID, but you can get one wherever you want. MAKE SURE YOU ALWAYS GET A NEW UUID! Do not use the one used in this function.

Just put that code in any JavaScript document that's loaded in your app, and your users will be connected!

3Now that you're registered, add whatever BBM Integrated function you want to an event, such as a button click. Some examples:
Allow users to update their BBM Status:

blackberry.bbm.platform.self.setPersonalMessage('I love OSBB!')

Allow people to change Availability Status:

blackberry.bbm.platform.self.setStatus('available', 'I\'m available!')

To invite other people to download your app:

blackberry.bbm.platform.users.inviteToDownload()

It really is that simple. So get out there, and integrate your apps with BBM!

 

Shane Cridlebaugh

Co-founder and legal nay-sayer of OSBB. Owner of SCrApps Application Development, WebWorks aficionado, Open Source contributor. SCrid2000 on most blogs. I build awesome BlackBerry apps when I'm not doing legal work or spending time with my wife and two boys.


Follow me on Twitter - @GShaneC

Check out my apps in BlackBerry World

Website: SCrApps.org
More in this category: « The Power of Ant Build

Leave your comments

Post comment as a guest

0

People in this conversation

Subscribe to the official OSBB BBM Channel!

osbbchannelQR

C00013E89

Back to top