Connect Everything to Everything Else With Trigger.io and PubNub

It’s a fascinating time to be a developer. As early as 2008 the number of things connected to the internet surpassed the number of people alive on earth, and some well informed people think the number could be as high as 50 billion by 2020.

iot.jpg

Users have been exposed to the type of user experience that realtime web technology provides, and expect those types of experiences in the apps they use.

Although realtime web technologies have been around for some time it’s only quite recently they’ve started to pervade everyday activities, such as hailing a taxi, keeping track of sports scores, bidding in an online auction or even opening the door to the garage.

Keep talking

Massive social platforms now represent one of the main ways that we communicate with each other. It’s realtime technologies that power the interactivity that make the experience so rewarding. Given the comprehensive toolsets provided by PubNub, implementing full-featured, massively scalable messaging has never been easier.

IoT and Really Big Numbers™

Talk about the Internet of Things (IoT) brings up numbers that can get anyone sweaty!

The global market is estimated to be worth $7.1 trillion by by 2020, or $14.4 trillion, according to Cisco. Less than 1% of things that could be connected to the Internet currently are, which means 10 billion things out of the 1.5 trillion that exist globally are currently connected. That’s a big gap, and a big opportunity.

Time-to-market has never been more key, nor a mature and well-developed technology stack.

PubNub

PubNub started life as a provider of APIs allowing publishers and developers to integrate messaging and social services on apps and websites.

iot.jpg

Since then their product offering has evolved into The PubNub Data Stream Network, a PAAS which allows rapid development of real-time apps and communication for web, mobile and IoT apps.

Their wide range of robust, friendly APIs merge seamlessly with Trigger.io’s fast, effective hybrid mobile runtime, bringing realtime technology to mobile.

PubSub

In software architecture, publish–subscribe is a messaging pattern where senders of messages, called publishers, do not program the messages to be sent directly to specific receivers, called subscribers. Instead, published messages are characterized into classes, without knowledge of what, if any, subscribers there may be. Similarly, subscribers express interest in one or more classes, and only receive messages that are of interest, without knowledge of what, if any, publishers there are.

Pub/sub is a sibling of the message queue paradigm, and is typically one part of a larger message-oriented middleware system.

This pattern provides greater network scalability and a more dynamic network topology, with a resulting decreased flexibility to modify the Publisher and its structure of the data published.

Using PubNub with Trigger.io

To demonstrate Pubnub’s ease of use I’m going to show you how to run PubNub’s 10chat 10-line Javascript chat sample inside a Trigger.io app.

Step 1

2.png

Create a new app in the Trigger Toolkit.

Step 2

3.png

Under Config / Tools, specify whether you want the app to run on a specific device or emulator, and specify the path to the appropriate SDK

Step 3

4.png

Now let’s give it a test run! Under Forge, click either Android or iOS to run it on the appropriate platform, or click Web to run it in a browser window.

You should now see something like this:

5.png

Step 4

So far so good, now let’s make it do something!

Find the index.html file in the src/ folder of your app, open it in the text editor of your choice and remove the template code between the <body></body> tags to leave you with something like this:

Step 5

Click here to go to PubNub’s 10chat demo page:

box.png

…now copy the 10chat javascript code from the code box into your app’s index.html file:

Step 6

Save the file, go back to the Trigger Toolkit and run the app again.

Now if you open the 10chat page in a web browser you’ll be able to chat back and forth between the two!

8.png

Learn More

We hope you enjoyed this short introduction.

For more in-depth tutorials on PubNub, please visit the PubNub Data Stream Tutorial page.

If you’re interested in learning more about using PubNub with Trigger.io please give us a ping at support@trigger.io, we’d love to hear from you!