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
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 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();
Ebay
Scopely Logo
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

Ready To Get Started?

Contact Sales