Five Ways You Can Use Presence

4 min read Michael Carroll on Mar 18, 2014

Waving Hand

Good News! We’ve launched an all new Chat Resource Center.

We recommend checking out our new Chat Resource Center, which includes overviews, tutorials, and design patterns for building and deploying mobile and web chat.

Take me to the Chat Resource Center →

With Presence, you’ll never be without the answer to this question (well at least in regards to who is using your app, who’s in your PubNub channel, and who’s offline). Presence detects when users enter or leave your app, and gives the online/offline status of machines and devices connected to your app or channel. But it goes beyond just giving you a roll call of users. You can also trigger events based on audience size, create custom user states, and much more.

And just in time, we recently made a major update to our existing Presence, and added three new features.

Manage vehicle fleets

Manage vehicle fleets with Presence

It’s not hard to manage four or five taxis at a time. But what if you have a fleet of hundreds, or even thousands of vehicles? Or what if you’re responsible for keeping tabs on an entire city’s worth of delivery trucks? Reliable and accurate fleet management is essential. Presence allows you to deliver a real-time view of fleet status and availability, detecting when vehicles are online, offline, full, or empty, all with the here_now() call.

You can also store custom data about each vehicle, and have the vehicle state reflect that in real time with customer user state. This allows you to set custom key/value data per user or device to track custom states and other user data. Know exactly what taxis are available, and which ones are full, the second their status changes.


Manage smart devices and machines

Manage smart devices and machines with Presence

These days, even your toaster seems to have an IP address. The rise of the Internet of Things is making your everyday devices smarter. Device and machine management works very much like fleet management, enabling you to monitor devices and machines, and trigger actions based on the device status. As more devices are built to be controlled with mobile and web apps, the need to monitor and manage these devices based on their status is vital.

Take Revolv for example, whose app gives the status of

linked up to their home automation solution:

Revolv app gives the status of every smart device using Presence

Trigger events based on audience size

Trigger events based on audience size with Presence

Events can be as simple as collapsing a chat room list once it hits 10 participants, or as complex as basing an entire promotions campaign on picking winners based on when they do a certain activity. With Presence, and more specifically the here_now() call lets you see how many users are on your channel, in which you can write logic around that number to trigger whatever action you want. For example, say you want to pick the 100th user as a winner, and trigger some sort of action around them. That can all be done using the PubNub here_now() call.


Detect online/offline users in real time text chat apps

Detect online/offline users in real time text chat apps with Presence

When building any real-time messaging, speed is paramount. Not just for sending messages between devices quickly, but also updating who is in the messaging app and who isn’t. Remember your AOL buddy list? Users need to know who is available to chat, and who is offline, to ensure a smooth real-time chat experience. Presence’s here_now() call, delivers user status in under 1/10 of a second.


WebRTC and VOIP Signaling

WebRTC and VOIP Signaling with Presence

PubNub makes it easy to signal between devices, for example, initiating a VOIP call or establishing an open WebRTC data channel. But how do you know who’s available to connect in the first place? With VOIP apps like Skype, users can see a green dot next to users who are online. Using PubNub’s here_now() call, your users can see who’s available to chat and who is offline, a staple feature of any VOIP app. With WebRTC it’s the same, whether you’re using it for Data Channel or video/voice calling.