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 notifications
lastMessage
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 session
Message
with type
media
the
body
property now is null (instead of placeholder about unsupported media messaging)
Client#connectionStateChanged
event: adding
disconnected
and
disconnecting
states
This 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 Channel
Promise<number>
with count of unread messages in the channel after the operation:
Channel.advanceLastConsumedMessageIndex
Channel.updateLastConsumedMessageIndex
Channel.setAllMessagesConsumed
Channel.setNoMessagesConsumed
Client
constructor
Client.initialize
function
Client.version
property now correctly displays Client's version
Channel.getUserDescriptors
Channel.sendMessage
method you can provide
FormData
(for browsers) or
SendMediaOptions
(browsers and node.js apps) to send media from your client
Message
class is extended with
type
attribute
Message
class is extended with
media
attribute which holds
Media
class instance
sendMediaMessage
permission for users to be able to send Media Messages
PushNotification
interface for push notification representation
Client#event:pushNotification
event
Client.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()
function
Client.getUserChannels()
function
Client#event:userInfoUpdated
event
Member.userInfo
property
Member#event:userInfoUpdated
event
UserInfo
class
Channel.getUserDescriptors()
function
ChannelDescriptor.isPrivate
property
ChannelDescriptor.lastConsumedMessageIndex
property
ChannelDescriptor.status
property
ChannelDescriptor.type
property
Client.getPublicChannelDescriptors()
function
Client.getSubscribedChannels()
function
Client.getSubscribedUsers()
function
Client.getUser(identity)
function
Client.getUserChannelDescriptors()
function
Client.getUserDescriptor(identity)
function
Client#event:userSubscribed
event
Client#event:userUnsubscribed
event
Client#event:userUpdated
event
Member.getUser()
function
Member.getUserDescriptor()
function
User
class
UserDescriptor
class
channelAdded
event for public channels being joined was correctly fired again
endpoint_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 forward
endpoint_id
will be ignored if specified with your access token
direction
parameter to channel.getMessage method.
backwards
is default direction to keep api compatible with previous versions
anchor
parameter in channel.getMessage method was incorrectly processed.
getChannelBySid
and
getChannelByUniqueName
directly after the client start
client.identity
property. Use client.userInfo.identity
client.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 manner
channel.getMessagesPaged
is removed
channel.getMessages()
returns paginator instead of array
userInfo#updated
event now also reports a name of a key which has been updated