One-on-One

To access MessageSDKBinding.iOS binding library

Include the MessageSDKBinding.iOS in the .cs file of your ViewController.

include-file

All the method calls will invoke their respective callback blocks as defined below.

1. Initialize CometChat object

private CometChat _cometChat = new CometChat("");

2. Subscribe to CometChat

Start receiving messages, user’s list and logged-in user’s profile data. mode signifies receiving messages with emoji support.

void SubscribeWithMode (bool mode, Action<NSDictionary> myInfo, Action<NSDictionary> onlineUsers, Action<NSDictionary> message, Action<NSDictionary> announcement, Action<NSDictionary> avchatMessage, Action<NSDictionary> actionMessage, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> myInfo
Invocation: When server sends an update related to logged-in user’s profile
Response: NSDictionary containing the current user’s profile.
Eg:

{
    "id"="5";
    "n"="MyName";
    "l"="MyLastName";
    "a"="avatar.png";
    "s"="available";
    "m"="I'm available";
}

(ii) Action<NSDictionary> onlineUsers
Invocation: When the server sends an updated user’s list
Response: NSDictionary containing the user’s list.
Eg:

{
    "_1" = {
        "id"="1";
        "n"="User1";
        "a"="avatar.png";
        "d"="1";
        "s"="available";
        "m"="I'm available";
    };
	
    "_2" = {
        "id"="2";
        "n"="User2";
        "a"="avatar.png";
        "d"="1";
        "s"="available";
        "m"="I'm available";
    };
}

(iii) Action<NSDictionary> message
Invocation: When a message is received
Response: NSDictionary containing messages and its details

Field ‘message_type’ indicates the type of received message.
Types of messages received in this callback:

message_type = 10: For normal text messages
message_type = 11: For join chatroom invite message
message_type = 12: For image messages
message_type = 13: For handwritten messages
message_type = 14: For video messages
message_type = 17: For audio messages
message_type = 18: For file messages

Eg:
Text message

{
    "id"= "64";
    "message"= "Hello";
    "self"= 0;
    "old"= "1";
    "sent"= 1411035449792;
    "from"= "73";
    "message_type" = 10;
}

Join Chatroom message

{
    "id"= "64";
    "message"= {
        "chatroom_id" = 23;
        "chatroom_name" = "test-ccc";
        "chatroom_password" = da39a3ee5e6b4b0d3255bfef95601890afd80709;
    };
    "self"= 0;
    "old"= "1";
    "sent"= 1411035449792;
    "from"= "73";
    "message_type" = 11;
}

Image message

{
    "id"= "64";
    "message"= "http://yoursite.com/cometchat/plugins/filetransfer/download.php
                file=a1d28da22369e330fab64e0250226d0b.png&unencryptedfilename=Image.png";
    "self"= 0;
    "old"= "1";
    "sent"= 1411035449792;
    "from"= "73";
    "message_type" = 12;
}

Handwritten message

{
    "id"= "64";
    "message"= "http://yoursite.com/cometchat/plugins/handwrite/uploads/9384627441b49aad5ef6bace29cdcd36.png";
    "self"= 0;
    "old"= "1";
    "sent"= 1411035449792;
    "from"= "73";
    "message_type" = 13;
}

Video message

{
    "id"= "64";
    "message"= "http://yoursite.com/cometchat/plugins/filetransfer/download.php?      
                file=a1d28da22369e330fab64e0250226d0b.png&unencryptedfilename=Video.mp4";
    "self"= 0;
    "old"= "1";
    "sent"= "1035449792;
    "from"= "73";
    "message_type" = 14;
}

Audio message

{
    "id"= "64";
    "message"= "http://yoursite.com/cometchat/plugins/filetransfer/download.php?      
                file=a1d28da22369e330fab64e0250226d0b.png&unencryptedfilename=sample.mp3";
    "self"= 0;
    "old"= "1";
    "sent"= "1035449792;
    "from"= "73";
    "message_type" = 17;
}

File message

{
    "id"= "64";
    "message"= "http://yoursite.com/cometchat/plugins/filetransfer/download.php?      
                file=a1d28da22369e330fab64e0250226d0b.png&unencryptedfilename=sample.txt";
    "self"= 0;
    "old"= "1";
    "sent"= "1035449792;
    "from"= "73";
    "message_type" = 18;
}

(iv) Action<NSDictionary> announcement
Invocation: When the admin sends a site-wide announcement
Response: NSDictionary containing the announcement message details.
Eg:

{
    "id"= "55";
    "m"="hello";
}

(v) Action<NSDictionary> avchatMessage
Invocation: When an audio video chat message is received
Response: NSDictionary containing audio video chat messages and its details
Eg:

{
    "to"= 105;
    "id"= "64";
    "message"="AVCHAT_CALL_ACCEPTED";
    "self"= 0;
    "old"= "1";
    "sent"= 1411035449792;
    "from"= "73";
    "message_type" = 31;
}

Field ‘message_type’ indicates the type of received message.
Types of messages received in this callback:

AVCHAT_CALL_ACCEPTED
message_type = 31: Audio video call request has been accepted

AVCHAT_INCOMING_CALL
message_type = 32: Incoming audio video call request

AVCHAT_INCOMING_CALL_USER_BUSY
message_type = 33: Incoming audio video call request while user is busy

AVCHAT_END_CALL
message_type = 34: Audio video call has been ended

AVCHAT_REJECT_CALL
message_type = 35: Audio video call request has been rejected

AVCHAT_CANCEL_CALL
message_type = 36: Audio video call has been cancelled

AVCHAT_NO_ANSWER
message_type = 37: No answer received for audio video call request sent

AVCHAT_BUSY_CALL
message_type = 38: Busy call received for audio video call request sent

(vi) Action<NSDictionary> actionMessage
Invocation: When server sends is typing status.
Response: NSDictionary containing the current user’s is typing status.
Eg:

{
    "action":"typing_start",
    "from":"12",
    "sent":"1450849776899"
}

OR

{
    "action":"typing_stop",
    "from":"12",
    "sent":"1450849780098"
}

(vii) Action<NSError> failure
Invocation: If there’s an error while subscribing
Response: NSError containing error code and message
Usage:

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

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

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

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

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

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

this._cometChat.SubscribeWithMode(true,
                             (dict) => { this.onMyInfoReceived(dict); },
                             (dict) => { this.onGetOnlineUsers(dict); },
                             (dict) => { this.onMessageReceived(dict); },
                             (dict) => { this.onAnnouncementReceived(dict); },
                             (dict) => { this.onAVChatMessageReceived(dict); },
                             (err) => { this.OnFailure(err);});

3. Send message

Send text/emoji message to another user by specifying userID. (Ensure that userID and message must not be nil or an empty string)

void SendMessage (string message, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When message is sent successfully
Response: NSDictionary containing the message details
Eg:

{
    "id"="71";
    "m"="Hi! How are you?";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending message
Response: NSError containing error code and message
Usage:

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

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

this._cometChat.SendMessage("Hi! How are you?",
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

4. Send Image

a) Send image message in the form of imageData to another user by specifying userID. (Ensure that imageData and userID should not be nil)

void SendImageWithData (NSData imageData, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When an image is sent successfully.
Response: NSDictionary containing the message id of image message and original image data.
Eg:

{
    "id"="71";
    "m"="<ffd8ffe0 00104a46 49460001 01010048 00480000 ffdb0043 00030202 02020203 02020203 03030304 06040404 04040806 
            06050609 080a0a09 0809090a 0c0f0c0a 0b0e0b09 090d110d 0e0f1010 11100a0c 12131210 130f1010 10ffdb00 430103
            03 03040304 08040408 100b090b>";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending image
Response: NSError containing error code
Usage:

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

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

this._cometChat.SendImageWithData(NSData imageData,
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

b) Send image at given imagePath to another user by specifying userID. The image file should exist at the given path location. (Ensure that nil or empty imagePath and userID should not be sent)

void SendImageWithPath (string imagePath, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When an image at specified path is sent successfully.
Response: NSDictionary containing the message id of sent image message and the original image path
Eg:

{
    "id"="71";
    "m"="/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/IMG1049.JPG";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending image
Response: NSError containing error code
Usage:

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

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

this._cometChat.SendImageWithPath("/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-
                                89146DF4D1EB/Documents/IMG1049.JPG",
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

5. Audio File

Send file at given audioPath to another user by specifying userID. The audio file should exist at the given path location. (Ensure that nil or empty audioPath and userID should not be sent)

void SendAudioWithPath (string audioPath, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When an audio file at specified path is sent successfully.
Response: NSDictionary containing the message id of sent file message and the original file path
Eg:

{
    "id"="71";
    "m"="/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/sample.mp3";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending audio file
Response: NSError containing error code
Usage:

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

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

this._cometChat.SendAudioWithPath("/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-
                                89146DF4D1EB/Documents/sample.mp3",
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

6. Send File

Send file at given filePath to another user by specifying userID. The file should exist at the given path location. (Ensure that nil or empty filePath and userID should not be sent)

void SendFileWithPath (string filePath, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When a file at a specified path is sent successfully.
Response: NSDictionary containing the message id of sent file message and the original file path
Eg:

{
    "id"="71";
    "m"="/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/sample.txt";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending the file
Response: NSError containing error code
Usage:

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

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

this._cometChat.SendFileWithPath("/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-
                                89146DF4D1EB/Documents/sample.txt",
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

7. Send Video

a) Send video at given videoPath to the userID specified. The video file should exist at the given path location and must be in mp4 format. (Ensure that videoPath and userID should not be nil or empty)

void SendVideoWithPath (string videoPath, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When a video at given path is sent successfully.
Response: NSDictionary containing the message id of the video message and the original video path
Eg:

{ 					
    "id"="74";
    "m"="/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/IMG0180.mp4";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending the video
Response: NSError containing error code
Usage:

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

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

this._cometChat.SendVideoWithPath("/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB
                                 /Documents/IMG0180.mp4",
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

b) Send video using NSURL to the userID specified. NSURL can be obtained either by accessing UIImagePickerControllerMediaURL property of a video when it is selected using UIImagePickerController or by converting path of the given video to NSURL. (Ensure that videoURL and userID should not be nil or empty)

void SendVideoWithURL (NSUrl videoURL, string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When video message is sent successfully using the given videoURL
Response: NSDictionary containing the message id of the sent video message and the original videoURL
Eg:

{
    "id"="71";				 
    "m"="Users/MyPC/Desktop/72fd88e9abc28c04ef4b98d3bd62b483.3gp -- file:///”
}

(ii) Action<NSError> failure
Invocation: If there’s an error while sending the video using given videoURL
Response: NSError containing the error code
Usage:

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

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

this._cometChat.SendVideoWithURL(NSUrl videoURL,
                             "2",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

8. Get user’s profile details

Get the profile details corresponding to the userID. This function can also be used to get logged-in user’s details. (Ensure that userID should not be nil or empty)

void GetUserInfo (string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When the profile details corresponding to the userID is requested .
Response: NSDictionary containing the user’s profile.
Eg:

{
    "id"="5";
    "n"="a";
    "l"="";
    "a"="img.png";
    "s"="available";
    "m"="I'm available";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while performing the operation
Response: NSError containing error code and message
Usage:

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

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

this._cometChat.GetUserInfo("5",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

9. Change online status

Change logged-in user’s status to ‘Available’, ‘Busy’, ‘Invisible’, ‘Offline’ by selecting the proper status value from enum STATUS_OPTIONS.

void ChangeStatus (nint status, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When the status is updated successfully.
Response: NSDictionary containing the success message.
Eg:

{
    "Message"="Change status successful";	
}

(ii) Action<NSError> failure
Invocation: If there’s an error while changing the user status.
Response: NSError containing the error code
Usage:

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

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

this._cometChat.ChangeStatus(0,
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

10. Change status message

To change logged-in user’s status message. (Ensure that statusMessage should not be nil or empty)

void ChangeStatusMessage (string statusMessage, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When the status message is updated successfully.
Response: NSDictionary containing the success message.
Eg:

{
    "Message"="Change status message successful"
}

(ii) Action<NSError> failure
Invocation: If there’s an error while changing user’s status message.
Response: NSError containing the error code
Usage:

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

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

this._cometChat.ChangeStatusMessage("Exam Time!!",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

11. Get the list of currently active users

void GetOnlineUsersWithResponse (Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When online user’s list is requested.
Response: NSDictionary containing the user’s list.
Eg:

{
    "_1" = {
        "id"="1";
        "n"="User1";
        "a"="avatar.png";
        "d"="1";
        "s"="available";
        "m"="I'm available";
    };	
    "_2" = {
        "id"="2";
        "n"="User2";
        "a"="avatar.png";
        "d"="1";
        "s"="available";
        "m"="I'm available";
    };
}

(ii) Action<NSError> failure
Invocation: If there’s an error while performing the operation
Response: NSError containing error code and message
Usage:

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

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

this._cometChat.GetOnlineUsersWithResponse((dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

12. Block User

To block the user corresponding to given userID. Once the user is blocked successfully, you will not be able to send/receive messages to/from the respective user.

void BlockUser (string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback:
– Action<NSDictionary> success
Invocation: Triggered when block user response is received.
Response: NSDictionary containing id of blocked user.
Eg:

{
    "id"="102";
}

– Action<NSError> failure
Invocation: Triggered when error occurs while blocking the given user.
Response: NSError object representing error.
Usage:

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

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

this._cometChat.BlockUser("102",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

13. Unblock User

To unblock user corresponding to given userID. Once the user is unblocked successfully, you will be able to send/receive messages to/from the respective user.

void UnblockUser (string userID, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback:
– Action<NSDictionary> success
Invocation: Triggers when the user is successfully unblocked.
Response: NSDictionary containing id of the unblocked user.
Eg:

{  
    "id"="102";
}

– Action<NSError> failure
Invocation: Triggers when an error occurs while unblocking the given user.
Response: NSError object representing error.
Usage:

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

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

this._cometChat.UnblockUser("102",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

14. Get list of blocked users

void getBlockedUsersList (Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When blocked user’s list is requested.
Response: NSDictionary containing the blocked user’s list.
Eg:

{
    "73"=
    {
        "id"="73";
        "name"="user73”;
    };
    "700"=
    {
        "id"="70";
        "name"="user70”;
    };
}

(ii) Action<NSError> failure
Invocation: If there’s an error while performing the operation.
Response: NSError containing the error code and message.
Usage:

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

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

this._cometChat.getBlockedUsersList((dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

15. Fetch all announcements

void GetAllAnnouncements (Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When announcements list is requested.
Response: NSDictionary containing the list of announcements.
Eg:

{
    "_2"=
    {
        "id"="2";
        "m"="Test 2";
        "t"="1416576762";
    };
    "_1"=
    {
        "id"="1";
        "m":"Announcements test";
        "t":"1416576743";
    }
}

(ii) Action<NSError> failure
Invocation: If there’s an error while fetching the announcements list.
Response: NSError containing error code and message.
Usage:

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

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

this._cometChat.GetAllAnnouncements((dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

16. Get chat history

To get chat history of particular user. Specify the friendID and messageID of the oldest message present in the application. The server will return messages exchanged prior to this given messageID. (Ensure that userID and messageID should not be nil or empty)

void GetChatHistoryOfUser (string friendID, string messageID, Action<NSDictionary> success, Action<NSError> failure);

Parameters:
(i) friendID: The id of the user with whom you want to fetch the conversation with.

(ii) messageID: The messages fetched will be before this particular ID. If you do not have any ‘messageID’ OR you want the entire messages history, pass @”-1” to get the messages. The number of messages is set from CometChat Administration panel.

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When chat history of user is received from server.
Response: NSDictionary containing the history messages.
Eg:

{
    history = (
    {
        from = 14;
        id = 4843;
        message = rty;
        "message_type" = 10;
        old = 1;
        self = 1;
        sent = 1429771974000;
    };
    {
        from = 14;
        id = 4844;
        message = reyrey;
        "message_type" = 10;
        old = 1;
        self = 1;
        sent = 1429771987000;
    };
    {
        from = 14;
        id = 4845;
        message = 57457;
        "message_type" = 10;
        old = 1;
        self = 1;
        sent = 1429772014000;
    };
    {
        from = 14;
        id = 4846;
        message = 457547457457;
        "message_type" = 10;
        old = 1;
        self = 0;
        sent = 1429772019000;
    }
    );
}

(ii) Action<NSError> failure
Invocation: If an error occurs while fetching chat history from server.
Response: NSError containing error code.
Usage:

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

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

this._cometChat.GetChatHistoryOfUser("14",
                             "4850",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

17. Translate Conversation

To translate ‘OneOnOne’ and ‘Chatroom’ conversations in the selected language. Refer to LANGUAGE enum for the language values.

void SetTranslationLanguage (nint language, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Usage:

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

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

this._cometChat.SetTranslationLanguage("French",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});
[cometchat setTranslationlanguage:French 
      success:^(NSDictionary *response) {  
    } failure:^(NSError *error) {
}];

18. To check whether CometChat is installed at the specified URL location, return the URL of CometChat installation directory. (Ensure that siteURL nil or empty)

void IsCometChatInstalled (string siteURL, Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When CometChat installation directory is found at specified URL.
Response: NSDictionary containing the exact location of CometChat installation directory.
Eg:

{
    "cometchat_url"="http://www.yoursite.com/cometchat”;
}

(ii) Action<NSError> failure
Invocation: If CometChat is not found at specified URL.
Response: NSError containing error code
Usage:

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

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

this._cometChat.IsCometChatInstalled("http://www.yoursite.com/",
                             (dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

19. To check whether plugins are enabled or disabled.

void GetPluginInfo (Action<NSDictionary> success, Action<NSError> failure);

Return type: void
Callback Blocks:
(i) Action<NSDictionary> success
Invocation: When plugin information is fetched successfully.
Response: NSDictionary containing plugins with enable/disable flag.
Eg:

{
    avchat_enabled="1";
    createchatroom_enabled="1";
    blockuser_enabled="0";
    mediasharing_enabled="1";
    chatroom_mediasharing_enabled="1";
    realtime_translate_enabled="0";
}

(ii) Action<NSError> failure
Invocation: If there’s an error while fetching plugin information.
Response: NSError containing error code.
Usage:

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

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

this._cometChat.GetPluginInfo((dict) => { this.OnSuccess(dict); },
                             (err) => { this.OnFailure(err);});

20. To set Development Mode On/Off.
If development mode is enabled (On), you can see request/response of SDK in console. To enable Development mode pass ‘flag’ as ‘YES’.

void SetDevelopmentMode (bool flag);

Return type: void
Usage:


this._cometChat.SetDevelopmentMode(true);

21. isTyping…
Now you can make your chat more alive by sending typing.. information to another user, so the other user will know you are typing some text to him.
Note that this feature will only work from CometChat v5.7 onwards and by using CometService.
To send a message that you are typing you need to use isTyping method. The syntax of this function is as follows:

void IsTyping (bool flag, string channel, Action<NSError> failure);

Parameters:
(i) flag: This is BOOL value, pass YES when you start typing, pass NO when you stop typing.
(ii) channel: This is the channel id to whom you are chatting with. You will get the channel from the user list as “ch” channel when you enable the CometService.

Return type: void
Usage:

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

this._cometChat.IsTyping(true,
                             "buddyChannel",
                             (err) => { this.OnFailure(err);});
OR

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

this._cometChat.IsTyping(false,
                             "buddyChannel",
                             (err) => { this.OnFailure(err);});

22. Check the logged-in status of the user

bool IsLoggedIn ();

Return type: BOOL
Usage:

this._cometChat.IsLoggedIn();

23. Unsubscribe

To stop receiving OneOnOne messages, user’s list and logged-in user’s profile data.

void Unsubscribe ();

Return type: void
Usage:

this._cometChat.Unsubscribe();

Please refer ‎error codes for failure responses.

Not finding what you need?

The CometChat team is here to help!