Introducing the AllJoyn plugin for Cordova

16 Feb

The AllJoyn protocol is an emerging leader in the device communications space. Think of it as “Internet of Things” on your local LAN — connecting your TV, lights, stereo and dishwasher to each other.

With active support from most major electronics manufacturers (see this incredibly large list) devices are starting to be released to the public.  All new LG smart TV’s have AllJoyn support, and LifX, an exciting new Kickstarter funded smart lightbulb is adding support now too.  Qualcomm is building AllJoyn enabled chipsets to go in all manner of upcoming consumer devices.  Perhaps the largest near term impact to users will be Microsoft’s Windows 10, which includes native AllJoyn support and will soon be on billions of devices.

Our team at Microsoft Strategic Engagements has been ramping up on the AllJoyn framework for a while now, and felt there was a large gap in usability and accessibility for developers who want to write applications to use this technology.  We wanted it to be easy for people to write cross-platform mobile applications without dealing with the complexity of the native code that makes up the AllJoyn SDK.

AllJoyn Plugin For Cordova

Cordova is the most robust option for cross platfom mobile development in Javascript and HTML.  It powers PhoneGap, Ionic, AppGyver and many other platforms.  Now you can build AllJoyn clients on all of them, targeting Windows RT, Windows Phone, iOS and Android.

The basis of this plugin was work to port the AllJoyn Thin Client library to additional platforms, and then build proxy layers to expose the native methods to platform specific languages (java, javascript, objective-c).

Finally, we wrapped the proxy layers with a common javascript API, which is exposed to your application for easier consumption.

Where To Get It

The core plugin lives on Github
But you can install it from the Cordova plugin repository, or install the latest directly from the repo


How To Use it

We have put together several samples to help you get started.  Each of them is a Cordova application based on the plugin.  You can clone them, add the plugin, and build/deploy them right away.

Controlling a TV

or check the blog post covering the sample.

and Andre’s in depth look at how he made it work.

Controlling a Lightbulb

and the blog post about the sample.

and Phong’s detailed blog post.

Peer to Peer chat

How to Setup and AllJoyn Router

A router is required on your network to use AllJoyn devices.  Read about setting up a router.


Current State

Today we have made our initial release, but we still have quite a few issues to work through over the coming weeks.  Some of the higher priority issues to be aware of are as follows.

Android proxy layer is not on par with iOS and Windows yet.  The plugin compiles on Android, but not all features are exposed to Javascript yet.  As such, we recommend using one of the other platforms for initial development – you’ll be able to add the Android platform easily in the future.

Cordova 4.2.0 has bugs related to Windows Projects.  A bug fix is committed to mainline Cordova for issues relating to cross-architecture projects and will be released with 4.2.1.  Right now you’ll need to install Cordova from source to target Windows.

Whats Next?

Well, a lot of work went into making the AllJoyn Thin Client more portable, so we want to take advantage of it.  We’ll be looking to get NPM packages out for NodeJS as well as Nuget packages for .Net developers.

Additionally, we are working to push back our additions to the AllJoyn Thin Client to the core SDK repository and eliminate our fork.

2 Replies to “Introducing the AllJoyn plugin for Cordova

  1. I’ve got a question regarding the implementation of application object interface methods. From the examples, it has been demonstrated how to call AllJoyn proxy object methods. But, how do you implement an AllJoyn method from the application object side? So far, I have been able to successfully listen for when an application object’s interface methods have been called. From here, I can change state, etc. on the service side. But, I’m stuck on how to return a value back to the method caller.

    For example, let’s say I have the following interface definition:

    var applicationObjects = [
    path: “/SimpleService”,
    interfaces: [
    “?getCounter >i”,
    “?setCounter i”,
    “?decrement >i”,

    Now, after connecting, registering the application object, etc. I can successfully listen for when one of these methods is called. E.g.

    allJoynBus.addListener([1, 0, 0, 2], ”, function(args) {
    console.log(“increment called! args = ” + args); //This will be printed after the client calls session.callMethod(…).

    What I would like to do at this point is return a value back to the caller. E.g.

    allJoynBus.addListener([1, 0, 0, 2], ”, function(args) {
    console.log(“increment called! args = ” + args);
    return 15; //This is what I would like to be return to the caller.

    However, any values I return in the listener’s callback do not seem to make it back to the client. Does this plugin support the ability to return values back to the caller? If so, how?

Leave a Reply

Your email address will not be published. Required fields are marked *