Level up your Twilio API skills in TwilioQuest, an educational game for Mac, Windows, and Linux. Download Now


Rate this page:

Thanks for rating this page!

We are always striving to improve our documentation quality, and your feedback is valuable to us. How could this documentation serve you better?

Initializing SDK Clients

Initializing Programmable Chat SDKs is an important step to ensure your client is ready to be used by the user. SDKs help put necessary data in place and set up event handlers for new messages and other events.


Once your Chat Client is fully synchronized at client startup:

  • The client is subscribed to events for all User Channels.
  • The Messages and Members collections are available for querying.
  • The only initially subscribed User in the system is that of the local, which will never be automatically unsubscribed.
  • Note: You must maintain a strong reference to the client object you receive, keeping it in scope for the entirety of your usage of the Chat Client. It is also important to call the shutdown method on the client when you are done before releasing it to ensure proper cleanup of shared resources.

No previously existing Messages are fetched for the client on load. These will be loaded when you call the getMessages method to fetch messages on demand. Messages are then cached and updated after loading.


  • You will receive an asynchronous callback from the create client method when the client has been successfully created and is being synchronized.
  • You will receive an event to the client's listener or delegate via the synchronizationStatusUpdated method with a value of StatusCompleted. This is your indication the client is ready for business, and all User Channels have been obtained and subscribed to.


The JavaScript client will retrieve the list of Subscribed Channels that a User is a Member of (or has been invited to) once that user logs into the client.

JavaScript SDKの挙動についてのいくつかのさらなる詳細:

  • It will subscribe to notifications for changes to the Subscribed Channel list itself
  • It will subscribe to events from each Subscribed Channel in the list
  • It will retrieve the FriendlyName , UniqueName, and Attributes for each Subscribed Channel in the list
  • It will not retrieve any Messages for individual Channels
  • It will retrieve Member lists for Channels
  • It will not retrieve nor subscribe to Users linked to Members of Subscribed Channels
  • It will retrieve a currently logged in User object and subscribe to this User's events

To load Messages for a Subscribed Channel and subscribe to other Channel-level events you will need to load individual Channels manually. More information on this can be found in the Channels and Messages guide.

Knowing When the SDK is Ready for Use

It is important to know when the SDK Client has completed its initialization and is ready for use. Once the client is connected, you can configure all your listeners, event handlers, and other logic.



Chat Clientは下記の2つのうちいずれかの方法でインストールできます:

Twilio.Chat.Client.create(token).then(client => {
    // Use client

Or asynchronously, waiting for the result:

let client = await Twilio.Chat.Client.create(token);
// Use client

*Note: The above examples are minimal. It may be necessary to control the token lifecycle with the assistance of the Access Manager.


First, we initialize the Chat Client. Here we provide an initial Access Token:

 NSString *token = <token goes here>;
    __weak typeof(self) weakSelf = self;
    [TwilioChatClient chatClientWithToken:token
                                    completion:^(TCHResult *result, TwilioChatClient *chatClient) { 
                                            weakSelf.client = chatClient;
                                     ... }];

The iOS Chat SDK then provides a TCHClientSynchronizationStatus delegate callback:

    - (void)chatClient:(TwilioChatClient *)client
    synchronizationStatusUpdated:(TCHClientSynchronizationStatus)status {
        if (status == TCHClientSynchronizationStatusCompleted) {
            // Client is now ready for business


The Android Chat SDK provides a Listener Interface which you must implement to check the init status and completion of the SDK client.

    ChatClient.Properties props = new ChatClient.Properties.Builder()

      new CallbackListener<ChatClient>() {
        public void onSuccess(final ChatClient client) {
          // save client for future use here
          client.setListener(new ChatClientListener() {
            public void onClientSynchronization(ChatClient.SynchronizationStatus status) {
              if (status == ChatClient.SynchronizationStatus.COMPLETED) {
                // Client is now ready for business, start working


Before we get too much deeper into showing how to get your users chatting, it's important to know where to look for logs and additional information if you need it. We have a guide about Error Handling and Diagnostics and Programmable Chat you may find helpful as you build your Chat integration.


すべてのチャットSDKクライアントはチャットサービスとの認証とやりとりを可能にする有効なアクセストークンが必要です。 アクセストークンは開発者のサーバーで生成されます - これについては「アクセストークンガイド」で説明しています。

The Access Token returned by your backend must be used when instantiating the SDK Client. You will pass the Token string directly to the SDK Client constructor method.

The SDK also provides a method to update the Access Token, which is used when you need to update the Access Token before expiration. Please see the Creating Access Tokens guide for more information.

次: アクセストークンの作成

Rate this page:


誰しもが一度は考える「コーディングって難しい」。そんな時は、お問い合わせフォームから質問してください。 または、Stack Overflow でTwilioタグのついた情報から欲しいものを探してみましょう。