Displaying UI ( iOS )

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 SDK.

The SDK provides you with below method to launch the UI. They are:

Launch CometChat

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

readyUIFIle readyui = new readyUIFIle();
public virtual void LaunchCometChat(
                                bool isFullScreen,
                                UIViewController currentView,
                                Action < NSDictionary > success,
                                Action < NSDictionary > UserInfo,
                                Action < NSDictionary > GroupInfo,
                                Action < NSDictionary > OnMessageReceive,
                                Action < NSError > failure,
                                Action < NSDictionary > onLogout
                    )

e.g

this.readyui.LaunchCometChat(true, this, 
                             (dict) => { this.OnSuccess(dict); /* code block /* },
                             (dict1) => { this.UserInfo(dict1); /* code block /* },
                             (dict2) => { this.GroupInfo(dict2); /* code block /* }, 
                             (dict3) => { this.OnMessageReceive(dict3); /* code block /* }, 
                             (err) => { this.OnFailure(err); /* code block /* }, 
                             (dict4) => { this.OnLogout(dict4); /* code block /* }
                             );

Where LaunchCallbacks is as follows :

   private void OnSuccess(NSDictionary dict)
        {
            Console.WriteLine("OnSuccess : " + dict);
        }

        private void UserInfo(NSDictionary dict1)
        {
            Console.WriteLine("UserInfo : " + dict1);
        }

        private void GroupInfo(NSDictionary dict2)
        {
            Console.WriteLine("GroupInfo : " + dict2);
        }

        private void OnMessageReceive(NSDictionary dict3)
        {
            Console.WriteLine("OnMessageReceive : " + dict3);
        }


        private void OnFailure(NSError err)
        {
            Console.WriteLine("OnFailure : " + err);
        }

        private void OnLogout(NSDictionary dict4)
        {
            Console.WriteLine("OnLogout : " + dict4);
        }

Launch one-on-one/ Group user chat window

You can use this method to open the chat window for any particular user or a Group. This method launches the chat window for the user/ group specified and allows you to chat with them easily.

public virtual void LaunchCometChat(
                                string groupUserId,
                                bool isGroup,
                                bool isFullScreen,
                                UIViewController currentView,
                                bool setBackButton,
                                Action < NSDictionary > success,
                                Action < NSDictionary > UserInfo,
                                Action < NSDictionary > GroupInfo,
                                Action < NSDictionary > OnMessageReceive,
                                Action < NSError > failure
                                Action < NSDictionary > onLogout
                    )

e.g

this.readyui.LaunchCometChat("5",false, true, this,true, 
                             (dict) => { this.OnSuccess(dict); /* code block /* },
                             (dict1) => { this.UserInfo(dict1); /* code block /* },
                             (dict2) => { this.GroupInfo(dict2); /* code block /* }, 
                             (dict3) => { this.OnMessageReceive(dict3); /* code block /* }, 
                             (err) => { this.OnFailure(err); /* code block /* }, 
                             (dict4) => { this.OnLogout(dict4); /* code block /* }
                             );

Where LaunchCallbacks is as follows :

   private void OnSuccess(NSDictionary dict)
        {
            Console.WriteLine("OnSuccess : " + dict);
        }

        private void UserInfo(NSDictionary dict1)
        {
            Console.WriteLine("UserInfo : " + dict1);
        }

        private void GroupInfo(NSDictionary dict2)
        {
            Console.WriteLine("GroupInfo : " + dict2);
        }

        private void OnMessageReceive(NSDictionary dict3)
        {
            Console.WriteLine("OnMessageReceive : " + dict3);
        }


        private void OnFailure(NSError err)
        {
            Console.WriteLine("OnFailure : " + err);
        }

        private void OnLogout(NSDictionary dict4)
        {
            Console.WriteLine("OnLogout : " + dict4);
        }

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.
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
successCallback This method is triggered once the request to launch CometChat is executed successfully
failCallback This is triggered when there is some issue when launching CometChat.
userInfoCallback This method is called when the user data is fetched from the server.
onGroupInfo 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