Returned client instance is not yet fully initialized. Calling any operations will block until it is. Use connection events to monitor when client becomes fully available (connectionStateChanged with state 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
Access token
Options to customize the Client
A not yet fully-initialized client.
Fired when a channel becomes visible to the client. The event is also triggered when the client creates a new channel. Fired for all channels client has joined.
Parameters:
channel
- the channel in questionFired when the client gets invited to a channel.
Parameters:
channel
- the channel in questionFired when a channel is no longer visible to the client.
Parameters:
channel
- the channel in questionFired when the attributes or the metadata of a channel have been updated. During channel's creation and initialization, this event might be fired multiple times for same joined or created channel as new data is arriving from different sources.
Parameters:
data
- info object provided with the event. It has the following properties:channel
- the channel in questionupdateReasons
- array of reasons for the updateFired when the connection is interrupted for an unexpected reason.
Parameters:
data
- info object provided with the event. It has the following properties:terminal
- Twilsock will stop connection attempts if truemessage
- the error message of the root causehttpStatusCode
- http status code if availableerrorCode
- Twilio public error code if availableFired when the connection state of the client has been changed.
Parameters:
connectionState
- the updated connection stateFired when a member's fields have been updated.
Parameters:
data
- info object provided with the event. It has the following properties:member
- the member in questionupdateReasons
- array of reasons for the updateFired when a new message has been added to the channel on the server.
Parameters:
message
- the message in questionFired when a message is removed from the message list of a channel.
Parameters:
message
- the message in questionFired when the fields of an existing message are updated with new values.
Parameters:
data
- info object provided with the event. It has the following properties:message
- the message in questionupdateReasons
- array of reasons for the updateFired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
Parameters:
pushNotification
- the push notification in questionFired when the token is about to expire and needs to be updated.
ttl
- token's time to liveFired when the token has expired.
Fired when the properties or the reachability status of a user have been updated.
Parameters:
data
- info object provided with the event. It has the following properties:user
- the user in questionupdateReasons
- array of reasons for the updateClient connection state.
Current version of the Chat client.
Current version of the Chat client.
Client reachability state. Throws if accessed before the client initialization was completed.
Information of the logged-in user. Before client initialization, returns an uninitialized user. Will trigger a Client.userUpdated event after initialization.
Create a channel on the server and subscribe to its events. The default is a public channel with an empty friendly name.
Options for the channel.
Get a known channel by its SID.
Channel sid
Get a known channel by its unique identifier name.
The unique identifier name of the channel.
Get an array of channels that are locally known to the client in the provided sorting order. Locally known channels are the ones that are created and/or joined during the client runtime and all the subscribed channel of the currently-logged-in user. To ensure that the full list of the subscribed channels has fetched, call the Client.getSubscribedChannels method and fetch all the pages with the help of the RestPaginator.nextPage method.
Sorting options.
Get the content of the public channels directory.
Get the current list of all the subscribed channels.
Get a list of subscribed user objects.
Gets a user with the given identity. If it's in the subscribed list, then return the user object from it; if not, then subscribe and add user to the subscribed list.
Identity of the user.
A fully initialized user.
Get the content of the channels directory of the user (created by, joined or invited to).
Gets the user descriptor for given identity.
Identity of the user.
The user descriptor.
Handle push notification payload parsing and emit the Client.pushNotification event on this Client instance.
Push notification payload
Register for push notifications.
Channel type.
Push notification ID provided by the platform.
Gracefully shut down the client.
Unregister from push notifications.
Channel type.
Update the token used by the client and re-register with the Programmable Chat services.
New access token.
Static method for push notification payload parsing. Returns parsed push as a PushNotification object.
Push notification payload.
A client is the starting point to the Twilio Programmable Chat functionality.