Sometimes you don’t have the time to read everything as soon as you discover it. It’s the same for users of your apps as well. For that reason it could be a good fit to add Pocket integration to your apps. For those of you who don’t know what Pocket is, it’s a so called “read it later” service, available cross platform for multiple devices. Pocket enables you to save everything you want to read for later, and access it on multiple devices and platforms. For more informations please have a look at GetPocket.com.

Pocket itself doesn’t offer a native BlackBerry 10 app. You can sideload the official android app, but that version does not integrate well with the BlackBerry 10 user interface and flow. But Pocket has a public API. ReadItNow! is probably the most popular and complete Pocket app for BlackBerry 10. It has been developed by myself over the past few years and it get’s continually updates. I’ve designed the app to be invoked by other BlackBerry 10 apps. For that reason it doesn’t need much effort at all, to integrate Pocket support for your own BlackBerry 10 app.

I’ve put together a few sniplets to show you how to integrate it with C++ and QML. It’s really easy, you will see.

Let’s start with the header file of the class, where you want to add the invocation. You should add the following lines to your header file:

In line 12 we’re defining a new function called check3rdPartyApps(). We’ll use it to detect automatically if the user has ReadItNow! installed on his device. As this check will be asynchronously, we need a slot for handling the response as well. The slot has been already defined in line 9 (onCheck3rdPartyAppsResponse()).

We’re using a InvokeQueryTargetsRequest in line 5 to search for apps that could handle “text/plain” mime type (line 6). We query the targets in line 7 and connect the finished() signal of that request with our onCheck3rdPartyAppsResponse() slot.

In our slot we iterate over all actions (line 23) and the corresponding targets (line 24). If the target name is “com.svzi.rin”, we found the app installed on that device. We need to remember that for later, so we set our class variable m_readitnowAvailable to true (line 27).

I usually call the check3rdPartyApps() in the constructor of my class, as well as every time the app got foregrounded. This way the user can start the app without having ReadItNow! installed, minimize your app, download ReadItNow! from the BlackBerry World and can use it right away, because you already checked and found it as your app got maximized again.

Now let’s share some content to ReadItNow!

There are two different ways to share content to ReadItNow:

Send an URL / URI

Send plain text, that will get parsed for any containing URLs!

For that reason we had defined two different methods in our header file (lines 2 and 3).

Before you start the invocation you should check if ReadItNow! was found on the device. If the app isn’t installed you could emit a signal, as shown in our example in line 13, to show a dialog or popup to the user and provide a link to the BlackBerry World to let him easily grab his copy of ReadItNow in order to use it with your app.

Back to the function. Lines 7 – 9 are defining the invocation request. As you can see the url parameter will be set as request URI. That’s all you need to do, to add Pocket support to your own app.

2) Send plain text, that will get parsed for any containing URLs!

But if you don’t want to share a simple URL, but a text containing one or more URLs, you need to add another function. But it doesn’t get complicated, it’s just as easy as sharing a single URL:

The only difference compared with our previous invocation is, despite the param name, the missing request.setUri(..). That call has been replaced with request.setData(…) in line 9. That’s all you need to do here as well. ReadItNow! will parse the text for any URLs and store every one of them to the users Pocket account.

What’s next?

Now you can can call either invokeReadItNowWithURL(…) or invokeReadItNowWithText(…). Whatever you want to save for later reading. You can call it from C++:

invokeReadItNowWithText("This string contains links like http://bit.ly/1VDf28P and http://blck.by/1MX2uHg ! Both will be stored to Pocket without any issues. :-)");

Who wants invocation?

Trust me, you do. Inter-app communication has always been a challenge for developers, and will continue to be one as the mobile landscape continues to expand. Users have an unwritten expectation that their apps should seamlessly work together…even in the enterprise. Unfortunately, not having control over other applications is the primary roadblock when it comes to communication between your app and another. BlackBerry 10 answered this call with our Invocation Framework on the initial release of BB10 OS, and has been refining it since.

Our online docs are great explaining how to use invocation in your app.We have a number of core apps that are invokable through the Invocation framework – to both Native and Hybrid apps.

What does Invocation truly mean?

If you were as impressed by our awesome invocation framework on BlackBerry 10 as I was, wait until you see what else you can do with it! First, the ability to launch any other app from your app is a powerful developer tool; it allows you to simplify your app by using the native viewers transparently. Because, after all, there’s no sense recreating the wheel! All of the maintenance, bug fixing and development can be maintained by the invokee and allow you to focus on what your app does best.

I’m sold, how does URI make it better?

The most popular Uniform Resource Identifiers (URIs) are http:, https: and file:. You can create a URI that will launch your app right now on BB10, and you can hand it a payload just like a URL in your browser. Not convinced that this is groundbreaking yet? Let’s look at a few scenarios:

You want to have your users run this great new app that you just pushed to them over the BES, but no one has heard of it yet, or even knows it’s there.

Sending a follow-up email with an embedded link, “myApp://” that they can click on and launch the app.

You want to launch your app from a notification in the HUB.

Send the link in your notification (for an example, the ECL application does this).

You got a support call and you need the user to launch the app with some debug flags.

Text or BBM them a link to “myApp:?mode=debug&data=my%20test%20data”. One click and they are on their way.

You want your app to be invokable by an already existing app.

They can just call your app by URI instead of recompiling invocation capabilities into their app. Simple, fast and extensible.

How do I invoke with a URI?

It’s incredibly simple:

Register your URI:

If it’s a WebWorks app, update your config.xml. It looks like this (from the ECL app):

<!-- This will cause the application to be opened -->

<rim:invoke-targetid="webworks2.ecl2.invoke.waa.open">

<type>APPLICATION</type>

<filter>

<action>bb.action.VIEW</action>

<action>bb.action.OPEN</action>

<propertyvar="uris"value="ecl:"/>

<mime-type>*</mime-type>

</filter>

</rim:invoke-target>

If it’s a Cascades/Native app, update your bar-descriptor.xml. Here is the example from the Cascades Webview app:

<!-- Allow myself to be invoked by uri "webview://" -->

<invoke-targetid="com.waa.WebView2">

<invoke-target-name>WebView</invoke-target-name>

<invoke-target-type>application</invoke-target-type>

<filter>

<action>bb.action.VIEW</action>

<mime-type>*</mime-type>

<propertyvar="uris"value="webview:"/>

</filter>

<invoke-target-pattern>

<pattern-valuetype="uri">webview:</pattern-value>

</invoke-target-pattern>

</invoke-target>

Install your app.

It is instantly available as an invocation target for other apps on your device.

Test it in a browser URL! Nothin’ to it but to do it!

Examples

HTML5 / Hybrid

The new ECL application makes use of invocation to launch from the HUB:

Native

Lastly, if you have any problems, reach out to your BlackBerry account manager for assistance. You are also welcome to tweet me @latestlinux, or post a comment below with any questions or suggestions.

]]>invoke_featureinsideblackberrybloginvokeinvokable appsinvoke screen shotsinvoke screen shots_2BlackBerry Jam Unplugged: BBM APIshttp://devblog.blackberry.com/2013/05/blackberry-jam-unplugged-bbm-apis/
Thu, 02 May 2013 14:41:47 +0000http://devblog.blackberry.com/?p=14802/ Read More]]>Hot off the press is the latest episode of the BlackBerry Jam Unplugged series where we learn a little more about BBM integration with BlackBerry 10.

We’ll be posting videos as part of this series leading up to BlackBerry Jam Americas in Orlando in order to give some more background surrounding the topics that we’ll be discussing in detail during the conference.

This particular video will give you some information about the upcoming roadmap items that we’re looking at for extending BBM capabilities for developers. In this video we’re joined by Nick Kalkounis to talk about new APIs that are coming to better connect your application through BBM.

]]>timneil1BlackBerry Jam Unplugged: Integrationhttp://devblog.blackberry.com/2013/04/blackberry-jam-unplugged-integration/
Thu, 25 Apr 2013 14:38:39 +0000http://devblog.blackberry.com/?p=14800/ Read More]]>We’ve now posted the latest episode of the BlackBerry Jam Unplugged series where we learn a little more about app integration into BlackBerry 10.

We’ll be posting videos as part of this series leading up to BlackBerry Jam Americas in Orlando in order to give some more background surrounding the topics that we’ll be discussing in detail during the conference.

This particular video will give you some information about the upcoming roadmap items that we’re looking at for further integration into BlackBerry 10. In this video we’re joined by Michael Clewley to talk about how integration with BlackBerry 10 can improve the user experience of your application.

If you’ve managed to get your hands on a BlackBerry® smartphone running BlackBerry® 6 (or a simulator of one), one of the first things you may have noticed is the new Home Screen interface. The new slider panes like Favorites and Frequent aren’t just fun to play with, but make it really easy for users to find their most frequently-used applications.

However, the best timesaver of all is the Unified Search framework, which is built right into the interface. Simply tap on the Search icon on the top right to bring up the Search field – or better yet, simply start typing directly on the home screen – and the search field will appear and populate automatically. With Unified Search, a user’s hunting days are over. Just start typing the name of the app on the home screen and the results will filter as they type.

Here’s an example of how I found and launched my “Hello World” app:

Now you might have noticed the additional Search Options within the last screenshot, such as “Search YouTube” and “Search BlackBerry App World”. These are what we like to call External Search Providers, and luckily for us, the BlackBerry Unified Search API allows any application to register itself as an External Search Provider. In a lot of cases, your application might already have a remote search service accessible over the web or a built-in search engine. By simply implementing the ExternalSearchProvider interface, your application can register and place its own customized icon within the Unified Search Framework. Once the user clicks on your icon, your application gets passed to the search query from the home screen, and it can then perform the search operation in its own way seamlessly. This is what we call Click-To-Search integration, and it’s perfect for search operations that are expensive or might take a while to complete.

The most important thing to remember when implementing the ExternalSearchProvider is to decide what type of content type(s) it will be searching. It is important to specify meaningful and relevant content types as this will directly impact where your application’s search icon appear(s) on the device. In addition, this will assist other third party clients using the Unified Search framework to provide relevant search options from within their applications. If relevant, feel free to combine multiple content types using bitwise parameters.

For example, a music store application should specify its’ content type as CONTENT_TYPE_MEDIA_MUSIC to ensure that its Search icon appears within the music library. Additionally, this allows other applications on the BlackBerry smartphone (like a radio player, perhaps) to query the Unified Search framework for a list of registered music search providers, so that it can extend additional capability (like purchasing) to those applications. This will be covered in more depth in a later post.

Here’s an example of how a music store with its own remote search engine could integrate using the ExternalSearchProvider interface: