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 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 alloc]init];

[cometchat loginWithURL:@”http://yoursite.com/cometchat” userid:@”5”  observer:self 
     success:^(NSDictionary *response) {
        /* Code Block */
    } userinfo:^(NSDictionary *response) {
        /* Code Block */
    } chatroominfo:^(NSDictionary *response) {
        /* Code Block */
    } onMessageReceive:^(NSDictionary *response) {
        /* Code Block */
    } failure:^(NSError *error) {
        /* Code Block */  
    }];

After:

CometChat *cometchat = [[CometChat alloc]init];  

[cometchat checkCometChatUrl:URLTextField.text success:^(NSDictionary *response) {
       /* Code Block */
    } failure:^(NSError *error) {
       /* Code Block */
    }];

[cometchat initializeCometChat:[response objectForKey:@"cometchat_url"] licenseKey:@"" apikey:@"" isCometOnDemand:NO 
    success:^(NSDictionary *response) {
       /* Code Block */
    } failure:^(NSError *error) {
       /* Code Block */
    }];    

Launch the CometChat UI

The loginWithURL() method used to launch cometchat depending on the requirement, whether to launch cometchat or not by providing a value to a parameter observer:self or observer:nil.
Before:

 [cometchat loginWithURL:@”http://yoursite.com/cometchat” userid:@”5”  observer:self 
     success:^(NSDictionary *response) {
        /* Code Block */
    } userinfo:^(NSDictionary *response) {
        /* Code Block */
    } chatroominfo:^(NSDictionary *response) {
        /* Code Block */ 
    } onMessageReceive:^(NSDictionary *response) {
        /* Code Block */
    } failure:^(NSError *error) {
        /* Code Block */ 
    }];

After:

    readyUIFIle *readyUI = [[readyUIFIle alloc]init];

    [readyUI launchCometChat:YES observer:self userInfo:^(NSDictionary *response) {
        /* Code Block */
    } groupInfo:^(NSDictionary *response) {
        /* Code Block */
    } onMessageReceive:^(NSDictionary *response) {
        /* Code Block */
    } success:^(NSDictionary *response) {
        /* Code Block */
    } failure:^(NSError *error) {
        /* Code Block */
    } onLogout:^(NSDictionary *response) {
        /* 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

[cometchat sendMessage:@"Hello" toUser:@"5"
       success:^(NSDictionary *response) {
         /* Code Block */      
     } failure:^(NSError *error) {
         /* Code Block */        
     }];    

Group Chat

[cometchat sendChatroomMessage:@"Hello" toChatroom:@"PublicLobby" withChatroomID:@"10"
       success:^(NSDictionary *response) {
         /* Code Block */      
     } failure:^(NSError *error) {
         /* 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.

[cometchat sendMessage:@"Hello!" toId:@"5" localID:@"" isGroup:NO
     success:^(NSDictionary *response) {
         /* Code Block */      
     } failure:^(NSError *error) {
         /* 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 sendAudioChatRequestToUser:@”5”
         success:^(NSDictionary *response) {
            /* Code Block */ 
       } failure:^(NSError * error) {
            /* Code Block */ 
       }];

After:

   [cometchat sendAudioChatRequest:@"5" isGroup:NO
        success:^(NSDictionary *response) {
            /* Code Block */ 
       } failure:^(NSError * error) {
            /* 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.

[audioChat sendAudioChatRequestToUser:@”5”
      success:^(NSDictionary *response) {
           /* Code Block */
      } failure:^(NSError *error) {
           /* Code Block */
 }];

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

[cometchat sendAVChatRequestToUser: @"5" 
      success: ^(NSDictionary *response) {
           /* Code Block */
      } failure: ^(NSError *error) {
           /* 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 sendAVBroadcastRequestToUser:@”5”
      success: ^(NSDictionary *response) {
           /* Code Block */
      } failure: ^(NSError *error) {
           /* Code Block */
      }];

After:

[cometchat sendAVBroadcastRequest:@"5"  isGroup:NO
      success: ^(NSDictionary *response) {
           /* Code Block */
      } failure: ^(NSError *error) {
           /* 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:

[groupAVChat sendConferenceRequest:@"5" 
      success: ^(NSDictionary *response) {
           /* Code Block */
      } failure: ^(NSError *error) {
           /* Code Block */
      }];

After:

[cometchat sendConferenceRequest:@"5"
      success: ^(NSDictionary *response) {
           /* Code Block */
      } failure: ^(NSError *error) {
           /* 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 Other Documentation Links section.

  • Was this helpful?
  • Yes   No