Class: Client

Client

A Client provides an interface for the local User to interact with Channels. The Client constructor will synchronously return an instance of Client, and will hold any outgoing methods until it has asynchronously finished syncing with the server.

new Twilio.Chat.Client()

Properties:
Name Type Description
reachabilityEnabled Boolean State of reachability feature
channels Map.<sid, Channel> A Map containing all Channels known locally on the Client. To ensure the Channels have loaded before getting a response, use Client#getChannels.
userInfo UserInfo User information for logged in user
connectionState Client#connectionState Connection state info
Fires:
  • Client#event:channelAdded
  • Client#event:channelInvited
  • Client#event:channelJoined
  • Client#event:channelLeft
  • Client#event:channelRemoved
  • Client#event:channelUpdated
  • Client#event:memberJoined
  • Client#event:memberLeft
  • Client#event:memberUpdated
  • Client#event:messageAdded
  • Client#event:messageRemoved
  • Client#event:messageUpdated
  • Client#event:typingEnded
  • Client#event:typingStarted
  • Client#event:userInfoUpdated
  • Client#event:connectionStateChanged

Members


connectionState

Methods


createChannel( [options])

Create a channel on the server.
Parameters:
Name Type Argument Description
options Client#CreateChannelOptions <optional>
Options for the Channel
Returns:
Type
Promise.<Channel>

getChannelBySid(channelSid)

Get a Channel by its SID.
Parameters:
Name Type Description
channelSid String The sid of the Channel to get.
Returns:
Type
Promise.<Channel>

getChannelByUniqueName(uniqueName)

Get a Channel by its unique identifier name.
Parameters:
Name Type Description
uniqueName String The unique identifier name of the Channel to get.
Returns:
Type
Promise.<Channel>

getPublicChannels()

Get the public channels directory content
Returns:
Type
Promise.<Paginator.<ChannelDescriptor>>

getUserChannels()

Get the current list of all Channels the Client knows about.
Returns:
Type
Promise.<Paginator.<Channel>>

handlePushNotification(notificationPayload)

Incoming push notification handler
Parameters:
Name Type Description
notificationPayload string Push notification payload

initialize()

Initializes library Library will be eventually initialized even without this method called, but client can use returned promise to track library initialization state. It's safe to call this method multiple times. It won't reinitialize library in ready state.
Returns:
Type
Promise.<Client>

setPushRegistrationId(channelType, registrationId)

Registers for push notifications
Parameters:
Name Type Description
channelType string 'gcm', 'apn' and 'fcm' are supported
registrationId string Push notification id provided by platform

shutdown()

Gracefully shutting down library instance

updateToken(token)

Update the token used by the Client and re-register with IP Messaging services.
Parameters:
Name Type Description
token String The JWT string of the new token.
Returns:
Type
Promise.<Client>