DEVELOPERS BLOG

Create Your Own URI for Invoking Apps

Guest post by Sebastian Barthelmess, Senior Enterprise Developer.

invoke

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.

invokable 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:

  1. 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.
  2. 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).
  3. 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.
  4. 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:

  1. 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>
  1. Install your app.
  2. 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:

And some eye-candy:

invoke screen shots

Native

The Cascades WebView example is an excellent example of passing data with the URI to search TMDB for a movie title.

Here is the screenflow from a browser URL in BlackBerry 10:

invoke screen shots_2

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.

BlackBerry

About BlackBerry

BlackBerry is an enterprise software and services company focused on securing and managing IoT endpoints.