If you are starting out with Twilio's Programmable Chat SDK for JavaScript, we highly recommend starting with version 4.x. Version 4.x is our latest SDK and it brings many new features and improvements to the 1.x and 2.x versions. And it will be much easier to migrate to Twilio Conversations.
Not using 4.x? You should migrate ASAP
If you are already using 2.x, we highly recommend planning your migration to 4.x as soon as possible.
End-of-Life for 1.x occurred on June 30, 2019.
Client.unsetPushRegistrationId
to deregister from push notificationslastMessage
structure to Channel
Client.getLocalChannels
to get (sorted) locally known channels, sorting is possible by uniqueName
, friendlyName
, or lastMessage
ClientOptions
between two clients creations in the same browser or node.js sessionMessage
with type media
the body
property now is null (instead of placeholder about unsupported media messaging)Client#connectionStateChanged
event: adding disconnected
and disconnecting
statesThis release is identical to 2.0.0. The sole purpose is to publish the new version to npmjs.com
.
Removed deprecated Client
constructor and Client.initialize
function, the correct way now is to use static function Client.create
.
Behavioral breaking change in adding Member and joining Channel, now if User is already in the Channel, then Channel.add
and Channel.join
will throw SessionError
. Changed function signature in Consumption Horizon functions, after successful setting of last message consumed these functions returns unread messages count in given Channel for logged in User.
Channel.add
and Channel.join
functions will throw an SessionError
in case of User already exists in the ChannelPromise<number>
with count of unread messages in the channel after the operation:
Channel.advanceLastConsumedMessageIndex
Channel.updateLastConsumedMessageIndex
Channel.setAllMessagesConsumed
Channel.setNoMessagesConsumed
Client
constructorClient.initialize
functionClient.version
property now correctly displays Client's versionChannel.getUserDescriptors
Channel.sendMessage
method you can provide FormData
(for browsers) or SendMediaOptions
(browsers and node.js apps) to send media from your clientMessage
class is extended with type
attributeMessage
class is extended with media
attribute which holds Media
class instancesendMediaMessage
permission for users to be able to send Media MessagesPushNotification
interface for push notification representationClient#event:pushNotification
eventClient.parsePushNotification
to handle push payload and return the PushNotification
instance back to client (intended use is Firebase service worker)deprecated
.messageRemoved
events were not correctly firing for messages that present at client init (i.e. not added after client init)With this release, Programmable Chat is now in GA. A number of breaking changes were introduced as part of the GA release. To see what has changed and to migrate from the latest Public Beta SDK to the new GA SDK, please read the * GA Migration Guide for JavaScript.
Client initialization has been simplified to reflect most users typical usage of the system. All user channels (channels for which the current user is joined to or an owner of) will be subscribed to from client startup but only the members roster will be synchronized initially. This keeps client startup fast while still reflecting the latest activity immediately to the client.
UserInfo
has been deprecated and replaced with two distinct classed, User
and UserDescriptor
. Similar to ChannelDescriptor
class, a UserDescriptor
represents a snapshot of data in time that should be utilized directly after obtaining it but not retained since it will not be updated with new data over time.
Users are no longer implicitly subscribed to improve performance on large instances. You can subscribe up to a maximum 100 of users at once after which your least recently subscribed User will be unsubscribed.
Client.getPublicChannels()
functionClient.getUserChannels()
functionClient#event:userInfoUpdated
eventMember.userInfo
propertyMember#event:userInfoUpdated
eventUserInfo
classChannel.getUserDescriptors()
functionChannelDescriptor.isPrivate
propertyChannelDescriptor.lastConsumedMessageIndex
propertyChannelDescriptor.status
propertyChannelDescriptor.type
propertyClient.getPublicChannelDescriptors()
functionClient.getSubscribedChannels()
functionClient.getSubscribedUsers()
functionClient.getUser(identity)
functionClient.getUserChannelDescriptors()
functionClient.getUserDescriptor(identity)
functionClient#event:userSubscribed
eventClient#event:userUnsubscribed
eventClient#event:userUpdated
eventMember.getUser()
functionMember.getUserDescriptor()
functionUser
classUserDescriptor
classchannelAdded
event for public channels being joined was correctly fired againendpoint_id
identifier specified in access tokens is now automatically generated and persisted in the client browser cache. The following should be observed with this change:
endpoint_id
is no longer a required identifier in your generated access tokens, you may omit it from this build forwardendpoint_id
will be ignored if specified with your access tokendirection
parameter to channel.getMessage method. backwards
is default direction to keep api compatible with previous versionsanchor
parameter in channel.getMessage method was incorrectly processed.getChannelBySid
and getChannelByUniqueName
directly after the client startclient.identity
property. Use client.userInfo.identityclient.getUserChannels
is now paged and returns only channels which
are related to the identity (statuses are: invited, joined, and
private channels)client.getPublicChannels
returns list of channelDescriptor, also in
paged mannerchannel.getMessagesPaged
is removedchannel.getMessages()
returns paginator instead of arrayuserInfo#updated
event now also reports a name of a key which has been updated