Migration Guide

In this release, we have completely revamped our SDK for easier integration and also provided you with a lot of more features. Since the SDK is built again from scratch, migrating from the old SDK to the new one will include a lot of changes.

The highlights of the changes in the new SDK are:
1. Starting this release, we provide you with a ready to integrate UI.
2. We also provide you with a sample application along with its codebase, for better understanding of how the SDK needs to be used.
3. We have changed the initialization mechanism.
4. All the SDK related methods that need to be invoked for the chat functionality, have been moved to a single class.

We strongly encourage you in moving to the latest SDK version from the previous version and here are the migration tips.

Initialization

The CometChat.getInstance() method does not take the apiKey parameter as earlier. The apiKey needs to be passed to the initializeCometChat method along with the site url, license key and a boolean to state if you are using the cloud version of cometChat or not. Before:

CometChat cometChat = CometChat.getInstance(Context context, String apikey);
cometChat.setCometChatUrl(String url);

After:

CometChat cometChat = CometChat.getInstance(Context context);
cometChat.initializeCometChat(siteUrl,licenseKey,apiKey,isCometOnDemand)

Launch the CometChat UI

The launchCometChat method has now been moved to the CometChat class and need to be invoked using the instcnce of the CometChat class Before:

 cometchatUI.launchCometChat(context,isFullScreen,new Callbacks() {
        @Override
        public void successCallback(JSONObject jsonObject) {
             /* Code Block */
        }

        @Override
        public void failCallback(JSONObject jsonObject) {
             /* Code Block */
        }
    });

After:

cometChat.launchCometChat(context,launcherActivity,isFullScreen,new Callbacks() {
        @Override
        public void successCallback(JSONObject jsonObject) {
             /* Code Block */
        }

        @Override
        public void failCallback(JSONObject jsonObject) {
             /* Code Block */
        }
    });

The new SDK also provides you with an option to launch the chat window for a particular user or any particular group. For more information, please look at out Displaying UIsection.

SDK Changes

One on one Chat and Group Chat:

One of the major changes in this release is that we have maintained the same methods for one on one and group chat activities. All these methods accept a boolean parameter that you need to use to specify if the activity is for a one on one chat or a group. 1. sendMessage: Before: One on one Chat

sendMessage(String RECEIVER_USER_ID, String messages, Callbacks callback)

cometChat.sendMessage("15", "Hi! How are you?", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Group Chat

sendMessage(String groupId, String message, Callbacks callbacks)

cometChat.sendMessage("5", "When you play a game of thrones you win or you die.", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

After: Both the above methods have been combined in one method which accepts a boolean parameter to distinguish between one on one chat and group chat.

sendMessage(String toId, String message,boolean isGroup, final Callbacks callbacks)

cometChat.sendMessage("10","Hello",true,new Callbacks(){
 @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

The boolean isGroup needs to be set to true if the message is to be sent to a group and should be set to false if the message is to be sent to a user. The toId parameter needs to set to the respective id of the user or the group. Similarly, all the other methods related to one on one and group chat now need to be invoked using the instance of the CometChat class. For more information please look at the One on one chat and the Group chat sections.

Audio Call

Earlier all the methods related to Audio Call were placed in the AudioChat class. As mentioned above, we have now moved all the Audio Call related methods to the CometChat class. So hereafter, all the methods related to Audio Call functionality, need to be invoked using the instance of the CometChat class. For example sendAudioChatRequest :

sendAudioChatRequest(String toId,Callbacks callback)

Before:

audiochat.sendAudioChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response) {
    }
    @Override
    public void failCallback(JSONObject response) {
    }
});

After:

cometChat.sendAudioChatRequest("15", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }
    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Similar changes need to be made to all the methods used to implement the Audio Chat feature. For more details on implementation of Audio Call please look at the Audio Call section.

Video Call

Similar to the Audio Call feature, all the methods used to implement the Video Call feature have been moved to the CometChat class. For example: sendAVChatRequest:

sendAVChatRequest(String userId, Callbacks callback )

Before: Earlier the method needed to be invoked using the instance of the AVChat class.

avchat.sendAVChatRequest(“15”, new Callbacks() {
    @Override
    public void successCallback(JSONObject response) {
    }
    @Override
    public void failCallback(JSONObject response) {
    }
});

After: Now the method needs to be invoked using the CometChat class instance.

cometChat.sendAVChatRequest("15", new Callbacks() {
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Similar to the above example, all the methods related to the Video call feature need to be invoked using the instance of the CometChat class. Please feel free to visit the Video Call section for more infromation.

Audio/Video Broadcast

Previously, all the methods related to the Audio/Video broadcast feature we present in the AVBroadcast class. Now as for all the other features, the methods related to the audio/video broadcast have been moved to the CometChat class. For example: sendAVBroadcastRequest:

sendAVBroadcastRequest(String toId, Callbacks callbacks)

Before:

avbroadcast.sendAVBroadcastRequest("15",new Callbacks() {
    @Override
    public void successCallback(JSONObject response) {
    }
    @Override
    public void failCallback(JSONObject response) {
    }
});

After:

cometChat.sendAVBroadcastRequest("15", new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Similar to the above example, all the methods that were previously invoked using the AVBroadcast class, need to be invoked using the CometChat class. Please look at the Audio/Video Broadcast section for more information.

Video Conference

The methods related to the video conference feature have been moved from GroupAVChat class to the CometChat class. For example: sendConferenceRequest

sendConferenceRequest(Callbacks callback )

Before:

grpavchat.sendConferenceRequest(new Callbacks() {
        @Override
        public void successCallback(JSONObject response) {
        }
        @Override
        public void failCallback(JSONObject response) {
        }
});

After:

cometChat.sendConferenceRequest(new Callbacks(){
    @Override
    public void successCallback(JSONObject response){ /* Code Block */ }

    @Override
    public void failCallback(JSONObject response){ /* Code Block */ }
});

Similar to the above example, all the methods related to the group conference need to be invoked using the CometChat class. For more information, please refer to our Group Conference section.

Emoji and Sticker Keyboards

Unlike before, the emoji keyboard and the sticker keyboard need not be added as separate library projects. We have added the keyboards to our SDK. The implementation for both these functionalities remains the same. However, if you would like to have detailed information regarding the implementation please refer to the Emoji and Sticker Keyboards section.

  • Was this helpful?
  • Yes   No