Skip to contentSkip to navigationSkip to topbar
Rate this page:
On this page

User Reachability Indicator


The Conversations SDKs include optional built-in presence functionality. You can use the Reachability Indicator feature to:

  • Check a Chat (SDK) User's status (i.e. online or offline)
  • Check if a User is notifiable via Push Notification
  • Receive SDK events when these statuses change

These properties will be available when you enable the Reachability Indicator feature.


Enable the Reachability Indicator

enable-the-reachability-indicator page anchor
(information)

Info

By default, the Reachability Indicator state is disabled.

To turn on the Reachability Indicator, you'll need to use the REST API.

Once you enable the feature, Twilio will automatically update and synchronize the state. The Reachability Indicator properties are exposed on the User resource in the REST API and on User objects in the SDKs. They are "read-only", which means you can't modify these properties.


Check the state of the Reachability Indicator

check-the-state-of-the-reachability-indicator page anchor

You can check User objects to determine their current reachability status and push notification availability.

Updates to other User's Reachability Indicator states are also communicated via the update event on User objects and the userUpdated event on the Client object.

Any of the following events can change the Reachability Indicator state:

  • When a User goes online
  • When a User goes offline
  • When a User registers for push notifications
  • When a User unregisters from push notifications
(information)

Info

Online/Offline status may take up to a couple of minutes to become consistent with a user's actual state.

Listening for Reachability status

listening-for-reachability-status page anchor
Node.js
Typescript

_32
/* Checking/listening to reachability */
_32
_32
// check if reachability function is enabled
_32
if (!client.reachabilityEnabled) {
_32
// reachability function is disabled for the client
_32
return;
_32
}
_32
_32
// listen to user reachability status updates
_32
client.on("userUpdated", ({ user, updateReasons}) => {
_32
if (updateReasons.includes("reachabilityOnline")) {
_32
// user reachability status was updated
_32
}
_32
_32
if (updateReasons.includes("reachabilityNotifiable")) {
_32
// user notifications status was updated
_32
}
_32
})
_32
_32
const participants = await conversation.getParticipants();
_32
_32
participants.forEach(async (participant) => {
_32
const user = await participant.getUser();
_32
_32
if (user.isOnline) {
_32
// conversation participant is online
_32
}
_32
_32
if (user.isNotifiable) {
_32
// user has push notifications active
_32
}
_32
});


Well done! You have learned about the User Reachability Indicator feature! As a following step, you can:


Rate this page: