The Conversations SDKs include optional built-in presence functionality. You can use the Reachability Indicator feature to:
These properties will be available when you enable the Reachability Indicator feature.
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.
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:
Online/Offline status may take up to a couple of minutes to become consistent with a user's actual state.
1/* Checking/listening to reachability */23// check if reachability function is enabled4if (!client.reachabilityEnabled) {5// reachability function is disabled for the client6return;7}89// listen to user reachability status updates10client.on("userUpdated", ({ user, updateReasons}) => {11if (updateReasons.includes("reachabilityOnline")) {12// user reachability status was updated13}1415if (updateReasons.includes("reachabilityNotifiable")) {16// user notifications status was updated17}18})1920const participants = await conversation.getParticipants();2122participants.forEach(async (participant) => {23const user = await participant.getUser();2425if (user.isOnline) {26// conversation participant is online27}2829if (user.isNotifiable) {30// user has push notifications active31}32});
Well done! You have learned about the User Reachability Indicator feature. As a following step, you can: