BB10: Introduction to the Invocation Framework

One of the major new features of BB10 is the ability for Apps to share data with each other. It’s called the Invocation Framework, and you can read all about it in the (slightly jumbled) docs here:

The basic idea is that your app registers for certain events types, and then it will be opened whenever an event of that type occurs. This has endless applications, the obvious ones are sharing text or images between apps, but it can be used for any type of data.

For example, lets say you’re writing a Twitter client, you would register for “bb.action.SHARE”, and then, when user’s select the “Share” option witin BB10, your app and it’s icon, will show up in the Share Menu. When the app is opened, you’ll receive a small data packet which contains the text they want to share!

It’s similar to Android Intents, or the “charms” bar in Windows 8, but in many aways much more powerful. The InvocationFramework differentiates itself in a few ways:

  • Apps can be overlayed on other apps by using ‘Cards’, These cards come in a number of styles and built in transitions. Cards can communicate events back to the calling app when they’re all done. Super cool stuff.
  • The Schema is easily extensible and very flexible, you can mix and match mimeTypes, fileTypes and other options.
  • Easily integrate with the Menu’s in the Core OS and other apps
  • Apps can query the OS for a list of Ivoke Targets, allowing them to build a list inside their app of potential share targets.

I have to give a hats off to Blackberry on this API, I haven’t dug super deep, but from what I’ve seen they’ve created a very slick system here that will blossom extremely quickly. It’s true they had the benefit of coming last, and they seem to have made good use of it.

Example Time!

For my purposes, I needed to allow my apps to handle Shared Images, here’s how that works.

Step 1: Declare your intentions!
The first step is to edit your blackberry-tablet.xml file (or whatever the kids are callin it these days…), and add the declaration for the types of InvokeEvents your app can handle.

Open up the XML file, and add the following:

<invoke-target id=”com.yoursite.YourApp”>
                  <property var=”uris” value=”file://”/>

For more information on what these fields mean, and the different options, check out the docs:

Step 2: Listen Up
The other half of this equation is to listen for incoming Invoke Events. This is super simple.

First, open up your document class, and register for the event with the InvokeManager:

public function MainConstructor(){
       InvokeManager.invokeManager.addEventListener(, onAppInvoke);

Then check out the invokeManager.startupRequest to access any incoming data:

protected function onAppInvoke( {
        //Regular nada.
	if(InvokeManager.invokeManager.startupMode == InvokeStartupMode.OPEN){
	//Invoked by another app
	if(InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE){
                //Check to see there's a valid StartupRequest
		var request:InvokeRequest = InvokeManager.invokeManager.startupRequest;
		if(request && request.uri){
			//Load the passed image!

That is basically all there is too it, and you are now integrated into the Core OS, handling any images sent your way :)

Written by

No Comments Yet.

Leave a Reply