Programmable Chat has been deprecated and is no longer supported. Instead, we'll be focusing on the next generation of chat: Twilio Conversations. Find out more about the EOL process here.
If you're starting a new project, please visit the Conversations Docs to begin. If you've already built on Programmable Chat, please visit our Migration Guide to learn about how to switch.
Twilio Programmable Chat is a highly customizable and flexible product with numerous great features. We've learned a lot with our customers and can provide some known best practices to make implementation easier and reliable.
SDK operates by sending commands to the backend and receiving updates from the backend over an independent channel. This means that most asynchronous operations require you to asynchronously wait for an update event before you could see actual updated values.
Push registration Time-To-Live (TTL) is 1 year of idle time - it is worth it to unregister from push notifications using SDK methods when re-launching applications with different Chat identity. Otherwise your app might receive pushes for the previously logged in user.
It is highly recommended to use several hours (up to 24H) for token's TTL.
Some additional details about the JavaScript SDK behavior:
Fetching of user's subscribed channels starts asynchronously and continues after Client instance is
resolved in Promise.
Due to (1) and (2) to get the list of subscribed channels, you will need first to subscribe to
Client#channelAdded
and Client#channelJoined
events and only after call the getSubscribedChannels
method.
getSubscribedChannels
is paginated, hence duplicated channels might arrive from two sources: from events and from this method call, it's up to the developer to resolve it.
Channel's Messages are not fetched on Channel load automatically - hence, only Channel#messageAdded
event is emitted on new messages.
Channel#messageUpdated
and
Channel#messageRemoved
events are emitted only on those fetched messages.
Some methods are semi-realtime, i.e. guarded by caching with some lifetime, calling them rapidly might not reflect actual value, but will catch up after cached value expires:
Channel.getMembersCount()
Channel.getMessagesCount()
Channel.getUnconsumedMessagesCount()
All these practices are applicable to Android and iOS Chat SDKs.
ChatClient.onCientSynchronization
callback with status equivalent to
.ALL
→ this means the synchronization operation has completed).
Next: Channels and Messages