<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>BlackBerry Developer Blog &#187; invoke</title>
	<atom:link href="http://devblog.blackberry.com/tag/invoke/feed/" rel="self" type="application/rss+xml" />
	<link>http://devblog.blackberry.com</link>
	<description></description>
	<lastBuildDate>Thu, 23 May 2013 15:14:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='devblog.blackberry.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://1.gravatar.com/blavatar/9ef0a66c09615fa946c4179662398878?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>BlackBerry Developer Blog &#187; invoke</title>
		<link>http://devblog.blackberry.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://devblog.blackberry.com/osd.xml" title="BlackBerry Developer Blog" />
	<atom:link rel='hub' href='http://devblog.blackberry.com/?pushpress=hub'/>
		<item>
		<title>Using the Invocation Framework with BlackBerry Messenger</title>
		<link>http://devblog.blackberry.com/2012/11/bbm-invocation-framework/</link>
		<comments>http://devblog.blackberry.com/2012/11/bbm-invocation-framework/#comments</comments>
		<pubDate>Thu, 22 Nov 2012 18:28:41 +0000</pubDate>
		<dc:creator>MSohm</dc:creator>
				<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[Platform Services]]></category>
		<category><![CDATA[bbm]]></category>
		<category><![CDATA[blackberry messenger]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[Invocation]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[Share]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=12233</guid>
		<description><![CDATA[My previous blog posts listed below covered the features offered by the BlackBerry® Messenger (BBM™) Social Platform at an API level: Integrate with BBM and Watch Your Application Go Viral How to Integrate Your Native Application with BBM How to Integrate Your BlackBerry WebWorks Application with BBM Now let’s take a look at how you [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=12233&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>My previous blog posts listed below covered the features offered by the BlackBerry® Messenger (BBM™) Social Platform at an API level:</p>
<p><a href="http://devblog.blackberry.com/2012/11/bbm-integration/" target="_new">Integrate with BBM and Watch Your Application Go Viral</a><br />
<a href="http://devblog.blackberry.com/2012/11/bbm-native-app-integration/" target="_new">How to Integrate Your Native Application with BBM</a><br />
<a href="http://devblog.blackberry.com/2012/11/blackberry-webworks-bbm-integration/" target="_new">How to Integrate Your BlackBerry WebWorks Application with BBM</a></p>
<p>Now let’s take a look at how you can use the invocation framework to invoke BlackBerry Messenger and bring cards from BBM into your application. In case the term card is new to you, let me explain. Think of cards as a screen of another application that is shown within your application and acts like a screen in your own app. A card becomes part of the flow that makes up BlackBerry® 10, allowing for a seamless user experience that prevents the user from having to switch applications.</p>
<p>The code samples used in this blog post are in QML, but keep in mind that you can use these invocation features from C++, BlackBerry® WebWorks™ and Adobe® AIR®.</p>
<p><span id="more-12233"></span></p>
<p>Below is a screenshot of the actions available that you could use in the menu of your application to invoke BBM. The “BBM Invocation” text you see below represents your application screen (it actually says BBM Invocation Sample). Each BBM card is going to be displayed on top of it. At any time the user can peek back to see your applications screen or close the card completely, returning to your application screen.</p>
<p>Let’s take a look at each of these cards individually, see how they’re invoked and what they look like once invoked.</p>
<p><img class="aligncenter size-full wp-image-12234" title="TITLE_IMAGE" alt="TITLE_IMAGE" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-1.jpg?w=288&#038;h=480" height="480" width="288" /></p>
<h3><strong>Start a BBM Chat</strong></h3>
<pre>InvokeActionItem {
    title: "Start BBM Chat"
    query {
        invokeActionId: "bb.action.BBMCHAT"
        uri: "pin:2100000a"
    }
}</pre>
<p>The code above shows how to initiate a BBM chat. The chat window will flow into your application as a card. In the example above, a single PIN is used. If you omit the URI parameter, the user will be prompted to choose a contact from their BBM contact list to include in the chat session. If a chat session already exists with the contact, it will be shown with previous messages populated.</p>
<p><img class="aligncenter size-full wp-image-12235" title="" alt="" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-2.jpg?w=288&#038;h=480" height="480" width="288" /></p>
<h3><strong>Set BBM Avatar Image</strong></h3>
<pre>InvokeActionItem {
    title: "Set BBM Avatar Pic"
    query {
        invokeTargetId: "sys.bbm.imagehandler"
        invokeActionId: "bb.action.SET"
        uri: "file:///path/to/the/file.png"
    }
}</pre>
<p>You can prompt the user to change their BBM avatar image to one specified by your application. This triggers a card that previews the image and allows the user to crop or zoom. Once the user is happy with their selection, they click Save to update their BBM Avatar.</p>
<p><img class="aligncenter size-full wp-image-12236" title="" alt="" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-3.jpg?w=288&#038;h=480" height="480" width="288" /></p>
<h3><strong>Invite to BlackBerry Messenger</strong></h3>
<pre>InvokeActionItem {
    title: "Invite to BBM"
    query {
        invokeActionId: "bb.action.INVITEBBM"
        uri: "pin:2100000A"
    }
}</pre>
<p>If you know the BlackBerry PIN for contacts who are not yet BlackBerry Messenger users, you can invite them to BBM by using the BlackBerry.action.INVITEBBM invoke action as shown above. The user can then write a personalized message to their contact before sending the message.</p>
<p><img class="aligncenter size-full wp-image-12237" title="" alt="" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-4.jpg?w=288&#038;h=480" height="480" width="288" /></p>
<h3><strong>Share Text over BBM</strong></h3>
<pre>InvokeActionItem {
    title: "Share Text Over BBM"
    query {
        mimeType: "text/plain"
        invokeTargetId: "sys.bbm.sharehandler"
        invokeActionId: "bb.action.SHARE"
        data: "This is some text to share."
    }
}</pre>
<p>Sharing text over BBM enables your application to start a chat session and populates the message entry field with the text specified in the data section. Just like starting a BBM chat session above, if a previous chat session exists, the message history will be shown.</p>
<p><img class="aligncenter size-full wp-image-12238" title="" alt="" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-5.jpg?w=288&#038;h=480" height="480" width="288" /></p>
<h3><strong>Share Image over BBM</strong></h3>
<pre>InvokeActionItem {
    title: "Share Image Over BBM"
    query {
        invokeTargetId: "sys.bbm.sharehandler"
        invokeActionId: "bb.action.SHARE"
        uri: "file:///path/to/image/file.png"
    }
}</pre>
<p>Sharing an image over BBM works almost the same way as sharing text, except you specify a URI that points to an image file. It brings up a chat card with a message composed and ready to send with the image attached.</p>
<p><img class="aligncenter size-full wp-image-12239" title="" alt="" src="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-6.jpg?w=287&#038;h=480" height="480" width="287" /></p>
<h3><strong>Wrapping It Up</strong></h3>
<p>For simplicity, the QML code samples above are using hard coded data and URI values. However, in a real application you’d want to use dynamic values based on variables within your application. You can do this using the onTriggered method. Here is an example of its use:</p>
<pre>InvokeActionItem {
    title: "Share Text Over BBM"
    query {
        mimeType: "text/plain"
        invokeTargetId: "sys.bbm.sharehandler"
        invokeActionId: "bb.action.SHARE"
        data: "This is some text to share."
    }
    onTriggered: {
        data = "Some new text"
    }
}</pre>
<p>When invoked, the sample above would populate the chat session with “Some new text”. In a real application you’d change the “Some new text” string to point to a variable or control in your application.</p>
<p>That concludes the list of BBM cards currently available for BlackBerry 10. As you can see, by using just a few lines of code you can integrate some powerful features like BBM Chat into your application. Invoke away!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/12233/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/12233/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=12233&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/11/bbm-invocation-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/76c7dc9f1e2068196cd724a8bd5bac54?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">msohm</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-1.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-4.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-5.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/11/bbm-invoke-framework-6.jpg" medium="image" />
	</item>
		<item>
		<title>Get Your Invoke On: BlackBerry 10 Invocation Framework</title>
		<link>http://devblog.blackberry.com/2012/08/blackberry-10-invocation-framework/</link>
		<comments>http://devblog.blackberry.com/2012/08/blackberry-10-invocation-framework/#comments</comments>
		<pubDate>Fri, 17 Aug 2012 14:18:52 +0000</pubDate>
		<dc:creator>Shadid</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 invocation framework]]></category>
		<category><![CDATA[bound invocation]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[sample code]]></category>
		<category><![CDATA[target]]></category>
		<category><![CDATA[unbound invocation]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10749</guid>
		<description><![CDATA[BlackBerry® apps have always been known for their ability to deeply integrate with core applications as well as with other third-party apps. With BlackBerry® 10, we are taking that experience to the next level with our Invocation Framework. It enables one application to request another to perform a specific task. For example, BlackBerry® Messenger (BBM™) [&#8230;]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10749&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p>BlackBerry® apps have always been known for their ability to deeply integrate with core applications as well as with other third-party apps. With BlackBerry® 10, we are taking that experience to the next level with our Invocation Framework. It enables one application to request another to perform a specific task. For example, BlackBerry® Messenger (BBM™) may request an app to open a .DOC file that it received in a chat session. But that’s just the tip of the iceberg &#8211; the framework streamlines the communication between apps and provides a consistently smooth and jitter-free user experience.</p>
<p>First and foremost, there are two kinds of invocations – unbound and bound. An unbound invocation is performed when an app does not specify a specific target app that should get invoked, and hence relies on the invocation framework to select the best target. For example, if there are three apps that can open .DOC files, the framework chooses the best one based on its own target selection logic. So, for unbound invocations, the framework provides automatic brokering to find the best-fit targets and also performs target selection to choose the best among the best. This is very powerful because the client application does not need to know any target applications at all, and yet it can discover and invoke them via the invocation framework.</p>
<p><span id="more-10749"></span></p>
<p><img class="aligncenter size-full wp-image-10751" title="" src="http://rimdevblog.files.wordpress.com/2012/08/invocation-framework-1.jpg?w=600&#038;h=422" alt="TITLE_IMAGE" width="600" height="422" /></p>
<p>On the other hand, a bound invocation is performed when the target app is specified by the client application while sending an invocation request. For example, a client app may request that Docs to Go® should be invoked for opening a .doc file. In this case, the invocation framework does not provide any brokering (or target selection) and blindly invokes the specified target app with the request parameters. Extra care must be taken when performing a bound invocation because an app may be sending a request to a target that the target does not understand at all. One thing is clear &#8212; bound invocation assumes that the client knows the target well.</p>
<p><img class="aligncenter size-full wp-image-10750" title="" src="http://rimdevblog.files.wordpress.com/2012/08/invocation-framework-2.jpg?w=600&#038;h=191" alt="" width="600" height="191" /></p>
<p>There are really two ways you can know a target. First, you might have had a conversation with the author of the target app and have an agreement on the invocation request parameters. In return, they have made you aware of their target ID that you can use to perform a bound invocation. Second, you can query the invocation framework with an invocation request to get a list of best-fit targets and programmatically parse their attributes (capabilities) including their target IDs and invoke one programmatically. Note that querying is another way to discover apps without knowing them and is even more powerful and flexible than unbound invocations. As long as you have a valid target ID, you can perform a bound invocation with the appropriate parameters.</p>
<p>So far so good, but how does the invocation framework know about all the target apps? It does because each target app is required to register with the framework if they wish to be considered by the framework. While registering with the framework, targets must specify a target id which alone makes them candidates for bound invocation. However if a target wants to make itself available for unbound invocations or invocation queries, it must define one or more invoke filters. Each filter is a combination of the following attributes.</p>
<ul>
<li>Actions (e.g. bb.action.OPEN) that describes the action it can perform</li>
<li>MIME types (e.g. application/pdf) describing the content type it can perform the action on</li>
<li>URIs (e.g. <a href="http://" rel="nofollow">http://</a>, file://) specifying the protocols it can handle to retrieve the data</li>
<li>EXTs describing the file extensions it can handle if the URI scheme is file://</li>
</ul>
<p>Note that at least one action and one MIME type is mandatory for each filter definition, and if the URI is file://, at least one EXT must be specified. Filters are what really allow the invocation framework to broker between clients and potential targets as well as target selection that lead to successful invocations.</p>
<p>Well, that’s a 30,000 feet overview of the invocation framework but as a developer I know your hands are itching for some real code. The good news is I have that covered &#8212; I have already uploaded a few sample applications on Github that you may find very (very) useful.</p>
<ul>
<li><a href="https://github.com/blackberry/Cascades-Samples/tree/master/invokeclient" target="_new">InvokeClient</a> – An application that demos different ways to invoke and to query for targets</li>
<li><a href="https://github.com/blackberry/Cascades-Community-Samples/tree/master/InvokeTarget1" target="_new">InvokeTarget1</a> – A dummy target app that can be used with InvokeClient</li>
<li><a href="https://github.com/blackberry/Cascades-Community-Samples/tree/master/InvokeTarget2" target="_new">InvokeTarget2</a> – A second dummy target app that can also be used with InvokeClient</li>
</ul>
<p>Samples are great, but so are documentations (if we read them) for a solid understanding. Please refer to our <a href="https://developer.blackberry.com/cascades/documentation/device_platform/invocation/index.html" target="_new">App Integration</a> development guide for a comprehensive guide with code snippets for both invoke clients and targets.</p>
<p>I am more excited than ever before to introduce the invocation framework as part of the <a href="https://developer.blackberry.com/cascades/download" target="_new">BlackBerry 10 Native SDK beta 2</a> and have no doubt that this will help most app developers out there to provide a deeply integrated user experience. Invocation is one of the core aspects of the BlackBerry 10 experience and come launch, it is going to be hard to find an app that does not invoke or get invoked. I will keep everyone posted on new features as we add them to this framework but more importantly, I am all ears to your feedbacks at shaque[at]rim[dot]com, <a href="http://twitter.com/BlackBerryDev" target="_new">@BlackBerryDev</a> and <a href="http://twitter.com/shadidhaque" target="_new">@shadidhaque</a>.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10749/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10749/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10749&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/08/blackberry-10-invocation-framework/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://2.gravatar.com/avatar/25ee80c29143f159bad70d24df820bc1?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">shadidhaque</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/invocation-framework-1.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/invocation-framework-2.jpg" medium="image" />
	</item>
		<item>
		<title>How to Write a Push-Enabled Application using BlackBerry WebWorks for BlackBerry 10</title>
		<link>http://devblog.blackberry.com/2012/08/blackberry-10-webworks-push-app/</link>
		<comments>http://devblog.blackberry.com/2012/08/blackberry-10-webworks-push-app/#comments</comments>
		<pubDate>Wed, 01 Aug 2012 17:49:40 +0000</pubDate>
		<dc:creator>Alex Kinsella</dc:creator>
				<category><![CDATA[How-to]]></category>
		<category><![CDATA[Native SDK Development]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 WebWorks]]></category>
		<category><![CDATA[blackberry webworks]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[push]]></category>
		<category><![CDATA[Push app]]></category>
		<category><![CDATA[Push Service API]]></category>
		<category><![CDATA[Push-Enabled]]></category>
		<category><![CDATA[sample code]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10546</guid>
		<description><![CDATA[Explaining how to write a good application using the BlackBerry WebWorks SDK.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10546&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><i>Guest post from Matthew D&#8217;Andrea &#8211; Ed.</i></p>
<p>You might have heard the terms “push” and “push notifications” thrown around before. So in a nutshell, what’s push good for? Push does pretty much what the name implies: it allows you to push information to BlackBerry® smartphones the moment it is available, and the user gets the push message almost immediately after it’s sent.</p>
<p>Push is an interesting technology because you need to write two applications for it to work:</p>
<p>1)	You have to write a server-side push application (sometimes called a <strong>Push Initiator</strong>) so that you can send out push messages to BlackBerry smartphones.<br />
2)	You also have to write a client-side push application (sometimes called a <strong>push-enabled application</strong>) so that users can receive those push messages on a BlackBerry smartphone.</p>
<p>I highly recommend that you look at the Push Service SDK to write your Push Initiator. You can download and find information on that SDK here: <a href="https://developer.blackberry.com/services/push" target="_new">https://developer.blackberry.com/services/push</a></p>
<p>The rest of this blog post concentrates on the push-enabled application, and explains how to write a good application using the BlackBerry® WebWorks™ SDK.</p>
<p><span id="more-10546"></span></p>
<p>The Push Service APIs that are part of the BlackBerry WebWorks SDK are brand new for BlackBerry® 10. When we created the APIs, our goal was to start fresh – to make things clean and simple. We also wanted to make sure that the Push Service APIs would work well with other new APIs introduced for BlackBerry 10, like invoke events (that is, the blackberry.invoked feature).</p>
<p>There are only two classes that you have to worry about in the Push Service APIs:</p>
<p>1)	<i>PushService</i> has the business logic that you need to start receiving push messages in your app</p>
<p>and</p>
<p>2)	<i>PushPayload</i> is essentially a value object containing the content and headers of your push message.</p>
<p>Now that you want your app to start receiving pushes, where do you start? The first question to ask yourself is whether or not you’re developing this app for the general public. If you are, you should register to evaluate the Push Service at this link: <a href="https://www.blackberry.com/profile/?eventId=8121" target="_new">https://www.blackberry.com/profile/?eventId=8121</a>  After registering, you’ll receive an email with all the information that you need to write your push-enabled application, including your application ID, password, and the PPG URL you will be pushing messages to. If you’re developing your app for enterprise users, you don’t have to worry about registering.</p>
<p>Alright, what’s next?</p>
<p>At some point, you should check out the <strong>Push Capture</strong> sample app available here: <a href="https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/pushCapture" target="_new">https://github.com/blackberry/BB10-WebWorks-Samples/tree/master/pushCapture</a>. The sample is a fully functional app that uses the Push Service APIs.</p>
<p>The UI for the sample app looks like this:</p>
<p><img src="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks.jpg?w=289&#038;h=480" alt="TITLE_IMAGE" title="" width="289" height="480" class="aligncenter size-full wp-image-10550" /></p>
<p>There are also a lot of good examples and information in the API Reference about the <i>PushService</i> and <i>PushPayload</i> classes. For information about the <i>PushService</i> class, see <a href="https://developer.blackberry.com/html5/apis/blackberry.push.PushService.html" target="_new">https://developer.blackberry.com/html5/apis/blackberry.push.PushService.html</a> For information about the <i>PushPayload</i> class, see <a href="https://developer.blackberry.com/html5/apis/blackberry.push.PushPayload.html" target="_new">https://developer.blackberry.com/html5/apis/blackberry.push.PushPayload.html</a></p>
<p>In order to use the Push Service APIs, you need to update your application’s <i>config.xml</i>:</p>
<p>1)	You need to reference the blackberry.push feature:</p>
<p><code>&lt;feature id=”blackberry.push” /&gt;</code></p>
<p>2)	You need to add a feature tag for blackberry.invoked:</p>
<p><code>&lt;feature id=“blackberry.invoked” /&gt;</code></p>
<p>This feature tag relates to the handling of invoke events. A push notification comes into your application as an invoke event.</p>
<p>3)	Finally, you need to have an entry relating to the invoke events that you receive for push messages:</p>
<p><img src="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-2.jpg?w=600&#038;h=148" alt="" title="" width="600" height="148" class="aligncenter size-full wp-image-10549" /></p>
<p>Take note of the id attribute (also known as the “invoke target id”). This attribute has to match the <i>options.invokeTargetID</i> that is passed in to the call to the static <i>create</i> function of the <i>PushService</i> class (more about the create function in a moment). Another important detail is that the action tag is set to “<code>bb.action.PUSH</code>”. This setting makes it clear that the invoke relates specifically to push messages.</p>
<p>Now, here’s a quick rundown of the Push Service APIs. Don’t worry, there aren’t many.</p>
<p>1)	Call the static <i>create</i> function on the <i>PushService</i> class to get a <i>PushService</i> object you can start using. If the <i>create</i> call fails, you won’t have access to a <i>PushService</i> object. That’s why the <i>create</i> function has success and fail callbacks. You’ll need a lot of the info from the email you received when you registered to evaluate the Push Service (for public apps), so have that info handy for this call.</p>
<p>2)	If your application is not running, one of the major advantages of push is to allow your application to be launched when a new push comes in, and to have your app continue to run in the background. This allows valuable device resources to be saved because your app doesn’t have to be running all the time to be able to receive push messages.</p>
<p>The default behavior for your application is to not have it launch when a new push comes in. That’s where the <i>launchApplicationOnPush</i> function comes in (from the <i>PushService</i> class). If you call it with a value of true, then it will activate the launch functionality. You can turn this functionality off at any time by calling <i>launchApplicationOnPush</i> again with a value of false.</p>
<p>3)	Call the <i>createChannel</i> function on your <i>PushService</i> object to allow pushes to start coming to your app.</p>
<p>When that’s done, how does the server-side Push Initiator know who to push to? There’s something we call a “token” that you get back when you do a <i>createChannel</i>. You need to pass the toke along to the Push Initiator so it knows who to address a push to. If you’re using the Push Service SDK I recommended above, then you just simply pass this token to the Push Initiator using an HTTP request (we call it a subscribe operation).</p>
<p>4)	Ok, you’re now ready to receive pushes (you created the channel) and you’re ready to send pushes (the Push Initiator has the token). Fire off a push to the token using your Push Initiator.</p>
<p>5)	In BlackBerry 10, the push comes to the app as an invoke event using the new blackberry.invoked feature in BlackBerry WebWorks. We register for the event with the following call:</p>
<p><img src="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-3.jpg?w=600&#038;h=33" alt="" title="" width="600" height="33" class="aligncenter size-full wp-image-10548" /></p>
<p>Now that we have the invoke request in our invokedCallbackFunc callback, how do we get the push out of it? Simply call the <i>PushService</i> object’s <i>extractPushPayload</i> function passing in the invoke request and it will give you back a <i>PushPayload</i> object.</p>
<p>(<strong>Quick side note:</strong> You’ll probably want to make sure the invoke event you received was for a push. The invoke event can be for other various reasons too. It’s easy to check though. Just make sure </p>
<p><img src="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-4.jpg?w=600&#038;h=28" alt="" title="" width="600" height="28" class="aligncenter size-full wp-image-10547" /></p>
<p>before you call <i>extractPushPayload</i>).</p>
<p>Here’s a link to the blackberry.invoked API Reference if you want to check it out: <a href="https://developer.blackberry.com/html5/apis/blackberry.invoked.html" target="_new">https://developer.blackberry.com/html5/apis/blackberry.invoked.html</a></p>
<p>6)	And there you go. You have the <i>PushPayload object</i>, and you can do whatever you want with the data.</p>
<p>You might have noticed that the “data” property of the <i>PushPayload</i> object is of type Blob. Look at the <i>extractPushPayload</i> function in the API Reference for <i>PushService</i> (see the link I gave above). It shows examples of how to convert that Blob into something that you can actually display to users.</p>
<p>7)	From this point onwards, you app will continue to receive push messages. If at any time you want your app to stop receiving push messages, simply call the <i>destroyChannel</i> function on your <i>PushService</i> object.</p>
<p>Sure, using push requires some extra effort. You do need to write two applications, but the benefits to your users are huge. Just imagine displaying notifications in your app the moment an event of interest happens in the real world. That’s a pretty powerful thing.</p>
<p>And that’s why the BlackBerry WebWorks SDK for the client-side application (and Push Service SDK for the server-side application) is there to help make your life easier and to use push to its full potential.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10546/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10546/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10546&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/08/blackberry-10-webworks-push-app/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/7d0e94a7e96e80d5911732d43f31a39c?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Alex K.</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-2.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-3.jpg" medium="image" />

		<media:content url="http://rimdevblog.files.wordpress.com/2012/08/r6-webworks-4.jpg" medium="image" />
	</item>
		<item>
		<title>Using the Invocation Framework from ActionScript</title>
		<link>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/</link>
		<comments>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/#comments</comments>
		<pubDate>Thu, 19 Jul 2012 13:11:44 +0000</pubDate>
		<dc:creator>Tim N.</dc:creator>
				<category><![CDATA[Adobe AIR Development]]></category>
		<category><![CDATA[How-to]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[adobe air]]></category>
		<category><![CDATA[API]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[beta]]></category>
		<category><![CDATA[BlackBerry 10]]></category>
		<category><![CDATA[BlackBerry 10 SDK]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[event]]></category>
		<category><![CDATA[invoke]]></category>
		<category><![CDATA[Invoke Framework]]></category>
		<category><![CDATA[invoking]]></category>

		<guid isPermaLink="false">http://devblog.blackberry.com/?p=10243</guid>
		<description><![CDATA[Examining the Invocation Framework included in the Beta 2 of the BlackBerry 10 SDK for Adobe AIR.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10243&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></description>
				<content:encoded><![CDATA[<p><img class="aligncenter size-full wp-image-10268" title="" src="http://rimdevblog.files.wordpress.com/2012/07/air-invoke.jpg?w=310&#038;h=197" alt="TITLE_IMAGE" width="310" height="197" /></p>
<p>Beta 2 of the BlackBerry® 10 SDK for Adobe® AIR® now has support for participating in the BlackBerry 10 Invoke Framework. You can find all of the APIs in the QNXDevice.ane and they are all documented.</p>
<h3><strong>Invoking a Application</strong></h3>
<p>By leveraging the Invoke API, you can invoke virtually any other application on the BlackBerry® smartphone through some simple API call, where you’ll set a parameter for the app you want to invoke and then pass in any parameters that application is expecting. A typical example would be that your application can invoke the BlackBerry® Maps application when it comes across an address. <code>InvokeManager.invoke()</code> will invoke an application.</p>
<p>When the application has been successfully invoked, an <code>InvokeEvent.INVOKE_TARGET</code> event will be dispatched. If there was an error invoking the target, an <code>ErrorEvent.ERROR</code> event will be dispatched. Please refer to the following <a href="http://supportforums.blackberry.com/t5/Test-Article-and-Discussion/Invocation-APIs-fail-when-using-the-BlackBerry-10-Dev-Alpha/ta-p/1819139/">Knowledge Base article</a> for details on some known issues which will be addressed in an upcoming patch.</p>
<p><span id="more-10243"></span></p>
<h3><strong>Invoking a Viewer</strong></h3>
<p><code>InvokeManager.invokeViewer()</code> will invoke a viewer. A Viewer class is returned and is used to communicate with the viewer.</p>
<p>Let’s say you have an image viewer application and you want to invoke it from the main application you’re working on. In the main application, you want to pass the image file that the imager viewer app will open when invoked.</p>
<p>Below is a sample of how you can invoke a viewer and wait for it to be created. This example assumes that you have created the <code>viewerRequest</code> object with the correct data for your viewer.</p>
<pre>var viewer:Viewer = InvokeManager.invokeManager.invokeViewer( viewerRequest );
viewer.addEventListener( ViewerEvent.VIEWER_CREATED, viewerCreated );

private function viewerCreated( event:ViewerEvent ):void
{
   //viewer is created and ready to communicate with.
}</pre>
<h3><strong>Making your Application an Invoke Handler</strong></h3>
<p>If you are developing an application that can be invoked by another application, you will want to add a listener for the invoke event at the very start of your application. These should be the first lines of your application.<br />
Once you have received the invoke event, you can check the startup mode and get the data that you were invoked with.<br />
Below is a sample of how you would accomplish this:</p>
<pre>InvokeManager.invokeManager.addEventListener(InvokeEvent.INVOKE, onInvoked );
private function onInvoked( event:InvokeEvent ):void
{
    if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE )
    {
        var invokeRequest:InvokeRequest = InvokeManager.invokeManager.startupRequest;
    }
    else if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.VIEWER )
    {
        var viewerRequest:InvokeViewerRequest = InvokeManager.invokeManager.startupViewerRequest;
    }
}</pre>
<h3><strong>Query a list of targets</strong></h3>
<p>You can also query a list of targets or viewers on the device by calling the <code>InvokeManager.queryTargets()</code> method. At some point in the future, this will make a pop-up list in your application that will allow users to select items from the list. For now, it returns the results and it is up to you to use those values in your <code>invoke()</code> and <code>invokeViewer()</code> calls.</p>
<h3><strong>InvokeEvent</strong></h3>
<p>No matter how your application is started, you will receive an InvokeEvent dispatched by the InvokeManager. In order to determine how your app was started, you can check the <code>InvokeManager.startupMode</code> in your InvokeEvent handler. So, your application would look something like the following, assuming that your application can be launched as a target and a viewer:</p>
<pre>package
{
    import qnx.events.InvokeEvent;
    import qnx.invoke.*;

    public class Main extends Sprite
    {

        public function Main()
        {
            //NOTE: THIS MUST BE THE FIRST THING SET IN YOUR APPLICATION CONSTRUCTOR
            InvokeManager.invokeManager.addEventListener(InvokeEvent.INVOKE, onInvoke );
        }

        private function onInvoke( event:InvokeEvent ):void
        {
            if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.INVOKE )
            {
                //invoked as an application/target.
                var data:InvokeRequest = InvokeManager.invokeManager.startupRequest;
            }
            else if( InvokeManager.invokeManager.startupMode == InvokeStartupMode.VIEWER )
            {
                //invoked as a viewer
                var data:InvokeViewerRequest = InvokeManager.invokeManager.startupViewerRequest;
            }
            else
            {
                //launched by the pressing on the icon on the home screen.
            }
        }
    }
}</pre>
<h3><strong>Closing a Viewer</strong></h3>
<p>There are two different ways a viewer can be closed:</p>
<ol>
<li>From the application</li>
<li>From the viewer</li>
</ol>
<p>When an application wishes to close a viewer that it has created, it can simply call the <code>Viewer.dispose()</code> method. This will cause the viewer to be removed immediately.</p>
<p>A viewer can request to be closed by the application and should never actually attempt to close itself directly. Viewers can call the <code>InvokeManager.requestViewerClose()</code> method. This will send a message to the application requesting that it be closed. The Viewer instance in the application will dispatch a <code>ViewerEvent.VIEWER_CLOSE_REQUEST</code> event. When application receives this event, it should call the <code>dispose()</code> method on the viewer to close it. The reason this doesn’t happen automatically is so that applications can transition viewers out before removing them. We may make this a bit more automated in the future, and we’ll let you know when this happens.</p>
<h3><strong>Viewer message relay</strong></h3>
<p>Viewers can send data to applications using the <code>InvokeManager.viewerSendMessage()</code> method. The Viewer instance will then dispatch <code>ViewerEvent.VIEWER_MESSAGE</code> events with the message and data properties set to what was passed into the <code>viewerSendMessage()</code>. Here is an example of how you would use this:</p>
<h3><strong>Viewer code</strong></h3>
<pre>InvokeManager.invokeManager.viewerSendMessage( "select", {name:"Fred"});</pre>
<h3><strong>App Code</strong></h3>
<pre>__currentViewer = InvokeManager.invokeManager.invokeViewer(viewerRequest);
__currentViewer.addEventListener( ViewerEvent.VIEWER_MESSAGE, onMessage );

private function onMessage( e:ViewerEvent ):void
{
    trace( e.message, e.data ); //outputs "select Fred";
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/rimdevblog.wordpress.com/10243/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/rimdevblog.wordpress.com/10243/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=devblog.blackberry.com&#038;blog=17235680&#038;post=10243&#038;subd=rimdevblog&#038;ref=&#038;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://devblog.blackberry.com/2012/07/using-the-invocation-framework-from-actionscript-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/3939390650b170ba28e9bf3c53d397ad?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">timneil1</media:title>
		</media:content>

		<media:content url="http://rimdevblog.files.wordpress.com/2012/07/air-invoke.jpg" medium="image">
			<media:title type="html">TITLE_IMAGE</media:title>
		</media:content>
	</item>
	</channel>
</rss>
