Device and User Presence

Device and User Presence

Automatic realtime detection of device and user state to identify who and what is connected.

Presence, powered by PubNub DSN, keeps a finger on the pulse, delivering up-to-the-millisecond status of users and devices. Beyond simply reading who is online and offline, Presence is flexible, enabling the streaming of realtime updates as device state changes (like typing indicators, whether a door is open or closed, and other sensor information). And, act on status updates by triggering PubNub Functions whenever an event occurs.

What Can You Do with Presence?

Online/Offline Status
Online/Offline Status

Signal other devices and servers as each user/device connects and disconnects.

Custom Status Changes
Custom Status Changes

Stream realtime updates as device state changes, like typing notices, battery drain, or temperature.

Trigger Functions and 3rd Party Services
Trigger Functions and 3rd Party Services

Trigger PubNub Functions whenever a presence event occurs, or webhooks on any presence join/leave event.

Actionable Updates
Actionable Updates

Pass customized information about the device for its last known state.

How It Works:
Code Example

  • JavaScript
  • Android/Java
  • iOS
  • .Net
  • pubnub.addListener({
  • presence: function(presenceEvent) {
  • console.log('presence event came in: ', presenceEvent)
  • }
  • });

  • pubnub.subscribe({ channels: ['ChatRoomChannel'],withPresence: true });
  • pubnub.addListener(new SubscribeCallback() {
  • @Override
  • public void presence(PubNub pubnub, PNPresenceEventResult presence) {
  • System.out.println(presence);
  • }
  • });

  • pubnub.subscribe().channels(Arrays.asList("ChatRoomChannel")).withPresence().execute();
  • class Listener: NSObject, PNObjectEventListener {
  • func client(_client: PubNub, didReceivePresenceEvent event: PNPresenceEventResult) {
  • print("Received presence event!!! \(event.debugDescription)")
  • }
  • }
  • let myListener = Listener()
  • client.addListener(myListener)
  • client.subscribeToChannels(["ChatRoomChannel"], withPresence: true)
  • SubscribeCallbackExt listenerSubscribeCallack = new SubscribeCallbackExt(
  • (pubnubObj, presence) => {
  • // handle incoming presence data
  • });

  • pubnub.AddListener(listenerSubscribeCallack);
  • pubnub.Subscribe<string>()
  • .Channels(new string[]{
  • // subscribe to channels
  • "ChatRoomChannel"
  • })
  • .Execute();
Quote

"PubNub enables a reliable, steady pipeline of communication to our devices within the home. That’s reliable and fast communication regardless of what the environment is. Whether you’re on your cellular data plan, where it’s maybe slow or spotty, or you’re at home, PubNub allows us to communicate the same way."

Hank Jacobs

Lead iOS Developer

Full Case Study

"Anything requiring realtime essentially uses PubNub. This includes control commands, baby status, state updates, and all the important logs. With PubNub, we are both reducing our risk and getting our product to market significantly faster."

Peter Fornell

VP of Product Development

Full Case Study
Ebay
Scopely Logo
Hubspot
Blue Jeans Network
Yesware
One Drop

SDKs and Resources

Getting Started Tutorial
Getting Started Tutorial

Setting up Presence and using different status events.

Read Basics Guide
SDKs + Documentation
SDKs + Documentation

70+ SDKs and comprehensive technical docs.

Read Docs

Try PubNub Today

Connect up to 100 devices for Free