User Presence

Endpoints

Requests should be sent to

https://us1.pusherplatform.io/services/chatkit_presence/v2/:instance_id

appended with the right endpoint for the resource you’re interested in. Your instance ID is available from your application dashboard. Your instance ID is the third component of your instance locator, for example v1:us1:instance_id.

Register as online

SUBSCRIBE /users/:user_id/register

A user with at least one active subscrition to this endpoint is considered online. When an offline user subscribes, anyone listening to their presence state will be informed that they have come online. Likewise, any listening user will be told when a user no longer has any active subscriptions, and has gone offline.

Example request

$ curl -X SUBSCRIBE \
  https://us1.pusherplatform.io/services/chatkit_presence/v2/:instance_id/users/:user_id/register

No events are sent on this subscription.

Listen to a user’s state

SUBSCRIBE /users/:user_id

Listen to a user’s presence state to find out whether they are online or offline, and to be told when their presence state changes.

Example request

$ curl -X SUBSCRIBE \
  https://us1.pusherplatform.io/services/chatkit_presence/v2/:instance_id/users/:user_id

Subscription events

Events come through on the subscription indicating whether the current user is online or offline.

1
2
3
4
5
6
7
{
  "event_name": "presence_state",
  "data": {
    "state": "online"
  },
  "timestamp": "2017-03-23T11:36:42Z"
}
1
2
3
4
5
6
7
{
  "event_name": "presence_state",
  "data": {
    "state": "offline"
  },
  "timestamp": "2017-03-23T11:36:42Z"
}