Displaying UI

Once the authentication is done, you can now launch the chat functionality directly in your app using the UI provided to you by the CometChat UI SDK.

The SDK provides you with different options to launch the UI. They are:

Launch CometChat

This option allows you to launch the entire chat functionality into your iOS application. Once launched all the functionalities are handled by the SDK and and you have a ready-to-go chat feature implemented in your iOS application.


-(void)launchCometChat:(BOOL)isFullScreen observer:(UIViewController *)currentView userInfo:(void (^)(NSDictionary *response))userInfo groupInfo:(void (^)(NSDictionary *response))groupInfo onMessageReceive:(void (^)(NSDictionary *response))onMessageReceive success:(void (^)(NSDictionary *response))success failure:(void (^)(NSError *error))failure onLogout:(void (^)(NSDictionary *response))onLogout;

[cometChat launchCometChat:YES observer:self userInfo:^(NSDictionary *response) { } groupInfo:^(NSDictionary *response) { } onMessageReceive:^(NSDictionary *response) { } success:^(NSDictionary *response) { } failure:^(NSError *error) { } onLogout:^(NSDictionary *response) { }];

Parameters
currentView – Instance of the current View Controller.
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
callbacks – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The methods in the callback provide you with the following information

Method Details
success This method is triggered once the request to launch CometChat is executed successfully
failure This is triggered when there is some issue when launching CometChat.
userInfo This method is called when the user data is fetched from the server.
groupInfo This method is triggered when the chatroom details are fetched by the server.
onMessageReceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.

Launch one-on-one user chat window

You can use this method to open the chat window for any particular user. This method launches the chat window for the user specified and allows you to chat with him/her easily.

-(void)launchCometChat:(NSString *)groupUserId
               isGroup:(BOOL)isGroup
          isFullScreen:(BOOL)isFullScreen
              observer:(UIViewController *)currentView
         setBackButton:(BOOL)flag
              userInfo:(void (^)(NSDictionary *response))userInfo
             groupInfo:(void (^)(NSDictionary *response))groupInfo
      onMessageReceive:(void (^)(NSDictionary *response))onMessageReceive
               success:(void (^)(NSDictionary *response))success
               failure:(void (^)(NSError *error))failure
              onLogout:(void (^)(NSDictionary *response))onLogout;

[cometChat launchCometChat:@"12" isGroup:NO isFullScreen:YES observer:self setBackButton:YES userInfo:^(NSDictionary *response) {

    } groupInfo:^(NSDictionary *response) {

    } onMessageReceive:^(NSDictionary *response) {

    } success:^(NSDictionary *response) {

    } failure:^(NSError *error) {

    } onLogout:^(NSDictionary *response) {

    }];


Parameters
currentView – Instance of the activity.
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
groupUserId – group id if you are launching a group window. User id of the user if u need to launch a user chat window.
isGroup – boolean value which needs to be set to true if you want to launch a group window. Else set it to false.
callbacks – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The methods in the callback provide you with the following information

Method Details
success This method is triggered once the request to launch CometChat is executed successfully
failure This is triggered when there is some issue when launching CometChat.
userInfo This method is called when the user data is fetched from the server.
groupInfo This method is triggered when the chatroom details are fetched by the server.
onMessageReceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.

Launch group chat window

This method can be used to open the chat window to any particular group.

-(void)launchCometChat:(NSString *)groupUserId
               isGroup:(BOOL)isGroup
          isFullScreen:(BOOL)isFullScreen
              observer:(UIViewController *)currentView
         setBackButton:(BOOL)flag
              userinfo:(void (^)(NSDictionary *response))userinfo
             groupInfo:(void (^)(NSDictionary *response))groupInfo
      onMessageReceive:(void (^)(NSDictionary *response))onMessageReceive
               success:(void (^)(NSDictionary *response))success
               failure:(void (^)(NSError *error))failure
              onLogout:(void (^)(NSDictionary *response))onLogout;

[cometChat launchCometChat:@"21" isGroup:YES isFullScreen:YES observer:self setBackButton:YES userInfo:^(NSDictionary *response) {

    } groupInfo:^(NSDictionary *response) {

    } onMessageReceive:^(NSDictionary *response) {

    } success:^(NSDictionary *response) {

    } failure:^(NSError *error) {

    } onLogout:^(NSDictionary *response) {

    }];


Parameters
Activity – Instance of the activity.
isFullScreen – A boolean value which when set to true launches the UI in full screen. Setting this value to false will launch the UI in a popup.
groupUserId – group id if you are launching a group window. User id of the user if u need to launch a user chat window.
isGroup – boolean value which needs to be set to true if you want to launch a group window. Else set it to false.
callbacks – This callback provides you with a set of methods to provide you information regarding the data fetched from the server.

The methods in the callback provide you with the following information

Method Details
success This method is triggered once the request to launch CometChat is executed successfully
failure This is triggered when there is some issue when launching CometChat.
userInfo This method is called when the user data is fetched from the server.
groupInfo This method is triggered when the chatroom details are fetched by the server.
onMessageReceive Any message received from the server triggers this method.
onLogout This callback method is invoked when the user logs out of the app.
  • Was this helpful?
  • Yes   No