To add One-on-One Chat support in your app,
Include the class <MessageSDKFramework/CometChat.h> in the .h file of your class.
Initialize CometChat object
CometChat *cometchat = [[CometChat alloc] initWithAPIKey:@"xxxxxx"];
Methods available:
subscribeWithMode
The method Starts receiving messages, user’s list and logged-in user’s profile data.
Method Signature:
(void)subscribeWithMode: (BOOL)mode
onMyInfoReceived: (void (^)(NSDictionary *))myInfo
onGetOnlineUsers: (void (^)(NSDictionary *))onlineUsers
onMessageReceived: (void (^)(NSDictionary *))message
onAnnouncementReceived: (void (^)(NSDictionary *))announcement
onAVChatMessageReceived: (void (^)(NSDictionary *))avchatMessage
onActionMessageReceived: (void (^)(NSDictionary *))actionMessage
onGetBotList: (void (^)(NSDictionary *))botList
failure: (void (^)(NSError *))failure;
Arguments:
mode:
mode is a boolean flag. If set to true, allows emoji in text messages.
onMyInfoReceived
onMyInfoReceived is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))myInfo |
Invocation: | When server sends an update related to logged-in user’s profile |
Response: | NSDictionary containing the current user’s profile. |
Sample Response:
{
"id" = "5";
"n" = "MyName";
"l" = "MyLastName";
"a" = "avatar.png";
"s" = "available";
"m" = "I'm available";
}
onGetOnlineUsers
onGetOnlineUsers is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))onlineUsers |
Invocation: | When the server sends an updated user’s list |
Response: | NSDictionary conta`ining the user’s list. |
Sample Response:
{
"_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";
};
}
onMessageReceived
onMessageReceived is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))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 | Description |
---|---|
10 | Text message |
11 | Invitation to join a group |
12 | Image file in a message |
13 | Image sent through Handwrite plugin |
14 | Video file in a message |
17 | Audio file in a message |
18 | a file other than audio, video or image in a message |
24 | a response from a bot |
Sample Responses:
a. Text Message:
{
"id" = "64";
"message" = "Hello";
"self" = 0;
"old" = "1";
"sent" = 1411035449792;
"from" = "73";
"message_type" = 10;
}
b. Invitation to join a group
{
"id" = "65";
"message" = {
"chatroom_id" = 23;
"chatroom_name" = "test-ccc";
"chatroom_password" = "da39a3ee5e6b4b0d3255bfef95601890afd80709";
};
"self" = 0;
"old" = "1";
"sent" = 1411035449792;
"from" = "73";
"message_type" = 11;
}
c. Image file in a message
{
"id" = "66";
"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;
}
d. Image sent through Handwrite plugin
{
"id" = "67";
"message" = "http://yoursite.com/cometchat/plugins/handwrite/uploads/9384627441b49aad5ef6bace29cdcd36.png";
"self" = 0;
"old" = "1";
"sent" = 1411035449792;
"from" = "73";
"message_type" = 13;
}
e. Video file in a message
{
"id" = "68";
"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;
}
f. Audio file in a message
{
"id" = "69";
"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;
}
g. File other than audio, video or image in a message
{
"id" = "70";
"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;
}
h. Bot Responses:
Bot can respond with text, image or anchor(hyperlink).
Bot response : Text
{
"bot_id" = 33;
"bot_response_type" = "text";
from = 98;
id = 29;
message = "hi this is a test message!";
"message_type" = 24;
old = 1;
self = 0;
sent = 1482401158;
}
Bot response : Image
{
"bot_id" = 30;
"bot_response_type" = "image";
from = 98;
id = 31;
message = "http://i.giphy.com/l2YWjLlllAFOkog9i.gif";
"message_type" = 24;
old = 1;
self = 0;
sent = 1482402757;
}
Bot response : Anchor
{
"bot_id" = 33;
"bot_response_type" = "anchor";
from = 98;
id = 46;
message = "hi this is a test message!<br><a href=\"https://app.bots.co/components/add/1164\">bots</a>";
"message_type" = 24;
old = 1;
self = 0;
sent = 1482403297;
}
onAnnouncementReceived
onAnnouncementReceived is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))announcement |
Invocation: | When the admin sends a site-wide announcement |
Response: | NSDictionary containing the announcement message details |
Sample Response:
{
"id" = "55";
"m" = "hello";
}
onAVChatMessageReceived
onAVChatMessageReceived is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))avchatMessage |
Invocation: | When an audio video chat message is received |
Response: | NSDictionary containing audio video chat messages and its details. |
Sample Response:
{
"to" = 105;
"id" = "12";
"message" = "AVCHAT_CALL_ACCEPTED";
"self" = 0;
"old" = "1";
"sent" = 1411035449792;
"from" = "73";
"message_type" = 31;
}
The available message types:
Message Type | message | Description |
---|---|---|
31 | AVCHAT_CALL_ACCEPTED | Audio video call request has been accepted by a callee |
32 | AVCHAT_INCOMING_CALL | Incoming audio video call request from a caller |
33 | AVCHAT_INCOMING_CALL_USER_BUSY | Message sent to callee indicating a new call while he is already answering another call |
34 | AVCHAT_END_CALL | Audio video call has been ended |
35 | AVCHAT_REJECT_CALL | Call has been rejected by callee |
36 | AVCHAT_CANCEL_CALL | Call has been rejected by caller |
37 | AVCHAT_NO_ANSWER | No answer from callee |
38 | AVCHAT_BUSY_CALL | Indicates caller that the callee is busy with another call |
onActionMessageReceived
onActionMessageReceived is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response)) actionMessage |
Invocation: | When server sends is typing status. |
Response: | NSDictionary containing the current user’s is typing status. |
Sample Responses:
{
"action" = "typing_start";
"from" = "12";
"sent" = "1450849776899";
}
OR
{
"action" = "typing_stop";
"from" = "12";
"sent" = "1450849780098";
}
onGetBotList:
onGetBotList is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))botList |
Invocation: | When the server sends an updated bot’s list |
Response: | NSDictionary containing the bot’s list |
Sample Response:
{
"_27" = {
a = "/cometchat/writable/bots/9GAG";
api = "aeb074769f5c4eac45137e874dd7719a91459352";
d = "";
id = 27;
n = 9GAG;
};
"_29" = {
a = "/cometchat/writable/bots/Weather";
api = "7c22b8c1a063df3009284fadc1892f692b6aa1c7";
d = "Keywords for this bot- weather";
id = 29;
n = Weather;
};
"_30" = {
a = "/cometchat/writable/bots/Giphy";
api = "07cf44c510682cf46f5fe18bc98337cea34a4caf";
d = "";
id = 30;
n = Giphy;
};
}
failure
failure is a callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there’s an error while subscribing |
Response: | NSError containing error code and message |
Usage:
[cometchat subscribeWithMode: YES
onMyInfoReceived: ^(NSDictionary *response){/* Code Block */}
onGetOnlineUsers: ^(NSDictionary *response){/* Code Block */}
onMessageReceived: ^(NSDictionary *response){/* Code Block */}
onAnnouncementReceived: ^(NSDictionary *response){/* Code Block */}
onAVChatMessageReceived: ^(NSDictionary *response){/* Code Block */}
onGetBotList: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendMessage
Sends text/emoji message to another user.
Method Signature:
(void)sendMessage: (NSString *)message
toUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
message:
The text message to be sent as NSString datatype.
userid:
The userid of a user to whom the message is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When message is sent successfully |
Response: | NSDictionary containing the message details |
Sample Response:
{
"id" = "71";
"m" = "Hi! How are you?";
}
failure
A callback Method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there’s an error while sending message |
Response: | NSError containing error code and message |
Usage:
[cometchat sendMessage: @"Hi! How are you?"
toUser: @"2"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendImageWithData
Sends image with image data.
Method Signature:
(void)sendImageWithData: (NSData *)imageData
toUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
imageData :
The image data to be sent as NSData datatype.
toUser:
The userid of a user to whom the image is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When image is sent successfully |
Response: | NSDictionary containing the message id of image message and original image data |
Sample Response:
{
"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>";
}
failure
A callback Method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there’s an error while sending the image. |
Response: | NSError containing error code and message. |
Usage:
[cometchat sendImageWithData: imageData
toUser: @"2"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendImageWithPath
Sends image at given path to another user.
Method Signature:
(void)sendImageWithPath: (NSString *)sendImageWithPath
toUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
imagePath:
The path of the image to be sent as NSString datatype.
toUser:
The userid of a user to whom the image is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When image is sent successfully |
Response: | NSDictionary containing the message id of image message and original image path |
Sample Response:
{
"id" = "71";
"m" = "/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/IMG1049.JPG";
}
failure
A callback Method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there’s an error while sending the image |
Response: | NSError containing error code and message |
Usage:
[cometchat sendImageWithPath:@"/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-
89146DF4D1EB/Documents/IMG1049.JPG"
toUser:@"2"
success:^(NSDictionary *response) {
}
failure:^(NSError *error) {
}
];
sendAudioWithPath
Sends an audio file at given path to another user.
Method Signature:
(void)sendAudioWithPath:(NSString *)audioPath
toUser:(NSString *)userID
success:(void(^)(NSDictionary *response))response
failure:(void(^)(NSError *error))failure;
Arguments:
audioPath:
The path of the audio file to be sent as NSString datatype.
toUser:
The userid of a user to whom the image is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When image is sent successfully |
Response: | NSDictionary containing the message id of image message and original image path |
Sample Response:
{
"id" = "71";
"m" = "/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/Sample.mp3";
}
failure
A callback Method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there’s an error while sending the image |
Response: | NSError containing error code and message |
Usage:
[cometchat sendAudioWithPath: @"/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/sample.mp3"
toUser: @"2"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendFileWithPath
Sends file from given path
Method Signature:
(void)sendFileWithPath: (NSString *)filePath
toUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
audioPath:
The path of the audio file to be sent as NSString datatype.
toUser:
The userid of a user to whom the image is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When an file at specified path is sent successfully |
Response: | NSDictionary containing the message id of sent file message and the original file path |
Sample Response:
{
"id" = "71";
"m" = "/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/sample.txt";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while sending file |
Response: | NSError containing error code |
Usage:
[cometchat sendFileWithPath: @“/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-
89146DF4D1EB/Documents/sample.txt”
toUser: @“2”
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendVideoWithPath
Sends video from given path
Method Signature:
(void)sendVideoWithPath: (NSString *)videoPath
toUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
videoPath:
The path of the video file to be sent as NSString datatype.
toUser:
The userid of a user to whom the video is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When an file at specified path is sent successfully |
Response: | NSDictionary containing the message id of sent file message and the original file path |
Sample Response:
{
"id" = "71";
"m" = "/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/VID0181.mp4";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while sending file |
Response: | NSError containing error code |
Usage:
[cometchat sendVideoWithPath: @"/var/mobile/Containers/Data/Application/F9778125-2506-4DED-9CDE-89146DF4D1EB/Documents/VID0181.mp4.txt"
toUser: @"2"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
sendVideoWithURL
Sends video using NSURL
Method Signature:
(void)sendVideoWithURL: (NSURL *)videoURL
toUser: (NSString *)userID
success: (void(^)(NSDictionary*response))response
failure: (void(^)(NSError *error))failure;
Arguments:
videoURL:
The path of the video file to be sent as NSURL datatype.
toUser:
The userid of a user to whom the video is being sent.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When video message is sent successfully using the given video URL |
Response: | NSDictionary containing the message id of sent video message and original video URL |
Sample Response:
{
"id" = "71";
"m" = "Users/MyPC/Desktop/72fd88e9abc28c04ef4b98d3bd62b483.3gp -- file:///”
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while sending video using given video URL |
Response: | NSError containing error code |
Usage:
[cometchat sendVideoWithURL: videoURL
toUser: @"2"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getUserInfo
Gets the profile details
Method Signature:
(void)getUserInfo: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
userID:
The userid of a user to whose profile details are needed.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | After successfully receiving the details |
Response: | NSDictionary containing the user’s profile. |
Sample Response:
{
"id" = "5";
"n" = "a";
"l" = "";
"a" = "img.png";
"s" = "available";
"m" = "I'm available";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while receiving the user details |
Response: | NSError containing error code |
Usage:
[cometchat getUserInfo: @"5"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
changeStatus
Changes logged-in user’s status to ‘Available’, ‘Busy’, ‘Invisible’, ‘Offline’ by selecting a value from enum STATUS_OPTIONS
.
Method Signature:
(void)changeStatus: (NSInteger)status
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
status:
A value from STATUS_OPTIONS
enum as NSInteger datatype.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When status is updated successfully. |
Response: | NSDictionary containing the success message |
Sample Response:
{
"Message" = "Change status successful";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while changing the user’s status |
Response: | NSError containing error code |
Usage:
[cometchat changeStatus: STATUS_AVAILABLE
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
changeStatusMessage
Changes logged-in user’s status message.
Method Signature:
(void)changeStatusMessage: (NSString *)statusMessage
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
statusMessage:
The status message to be set as NSString datatype.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When an file when the status message is set successfully |
Response: | NSDictionary success message |
Sample Response:
{
"Message" = "Change status message successful"
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while setting the status message |
Response: | NSError containing error code |
Usage:
[cometchat changeStatusMessage: @"Happy Hours"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getOnlineUsersWithResponse
Gets the list of currently active users
Method Signature:
(void)getOnlineUsersWithResponse: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
response
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When users list is received |
Response: | NSDictionary containing the users list |
Sample Response:
{
"_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";
};
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while receiving the list |
Response: | NSError containing error code |
Usage:
[cometchat getOnlineUsersWithResponse: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
blockUser
Blocks a user
Method Signature:
(void)blockUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
userID:
The userid of a user to block as NSString datatype.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When user is blocked successfully |
Response: | NSDictionary containing id of blocked user |
Sample Response:
{
"id" = "102";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while blocking a user |
Response: | NSError containing error code |
Usage:
[cometchat sendVideoWithPath: @"102"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
unblockUser
Unblocks a blocked user.
Method Signature:
(void)unblockUser: (NSString *)userID
success: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
userID:
The userid of a user to unblock as NSString datatype.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When user is blocked successfully |
Response: | NSDictionary containing id of unblocked user |
Sample Response:
{
"id" = "102";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while unblocking the user |
Response: | NSError containing error code |
Usage:
[cometchat sendVideoWithPath: @"102"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getBlockedUsersList
Gets the list of blocked users
Method Signature:
(void)getBlockedUsersList: (void(^)(NSDictionary *response))response
failure: (void(^)(NSError *error))failure;
Arguments:
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When list of blocked users received successfully |
Response: | NSDictionary containing the blocked users list |
Sample Response:
{
"73" =
{
"id" = "73";
"name" = "user73”;
};
"700" =
{
"id" = "70";
"name" = "user70”;
};
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while receiving a list of blocked users |
Response: | NSError containing error code |
Usage:
[cometchat getBlockedUsersList: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getAllAnnouncements
Gets announcements added from CometChat Admin Panel
Method Signature:
(void)getAllAnnouncements: (void (^)(NSDictionary*response))response
failure: (void (^)(NSError *error))failure;
Arguments:
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When announcements are received successfully |
Response: | NSDictionary containing the announcements |
Sample Response:
{
"_2" =
{
"id" = "2";
"m" = "Test 2";
"t" = "1416576762";
};
"_1" =
{
"id" = "1";
"m":"Announcements test";
"t":"1416576743";
}
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while receiving the announcements |
Response: | NSError containing error code |
Usage:
[cometchat getAllAnnouncements: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getChatHistoryOfUser
Gets the chathistory of a user
Method Signature:
(void)getChatHistoryOfUser: (NSString *)userID
messageID: (NSString *)messageID
success: (void(^)(NSDictionary*response))response
failure: (void(^)(NSError *error))failure;
Arguments:
userID:
The id of the user with whom you want to fetch the conversation with as NSString datatype.
messageID:
Message id from which you want to get the earlier messages.
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When chat history of user is received from server |
Response: | NSDictionary containing the messages |
Sample Response:
{
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;
}
);
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If an error occurs while fetching chat history from server |
Response: | NSError containing error code |
Usage:
[cometchat getChatHistoryOfUser: @"14"
messageID: @"4850"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
setTranslationLanguage
Translates the conversation to a selected language
Method Signature:
(void)setTranslationLanguage: (NSInteger)language
success: (void(^)(NSDictionary*response))response
failure: (void(^)(NSError *error))failure;
Arguments:
language:
Language code from LANGUAGE enum as NSInteger datatype
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When translation language set successfully |
Response: | NSDictionary containing the success message |
Sample Response:
{
"Message" = "Translation language set successful"
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while setting a translation language |
Response: | NSError containing error code |
Usage:
[cometchat setTranslationlanguage: French
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
isCometChatInstalled
Checks if CometChat is installed on the server
Method Signature:
(void)isCometChatInstalled: (NSString *)siteURL
success: (void(^)(NSDictionary*response))response
failure: (void(^)(NSError *error))failure;
Arguments:
siteURL:
Site URL as NSURL datatype
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When CometChat installation directory is found at site URL. |
Response: | NSDictionary containing the URL of CometChat installation |
Sample Response:
{
"cometchat_url" = "http://www.yoursite.com/cometchat”;
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If CometChat is not found at specified URL |
Response: | NSError containing error code |
Usage:
[cometchat isCometChatInstalled: @"http://www.yoursite.com/"
success: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
getPluginInfo
Checks whether plugins are enabled or disabled.
Method Signature:
(void)getPluginInfo: (void (^)(NSDictionary *response))response
failure: (void (^)(NSError *error))failure;
Arguments:
success
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSDictionary *response))response |
Invocation: | When plugin information is fetched successfully from the server |
Response: | NSDictionary containing plugins with enable/disable flag |
Sample Response:
{
avchat_enabled="1";
createchatroom_enabled="1";
blockuser_enabled="0";
mediasharing_enabled="1";
chatroom_mediasharing_enabled="1";
realtime_translate_enabled="0";
}
failure
A callback method.
Method Property | Description |
---|---|
Method Signature: | (void(^)(NSError *error))failure |
Invocation: | If there is an error while fetching plugin information |
Response: | NSError containing error code |
Usage:
[cometchat getPluginInfo: ^(NSDictionary *response){/* Code Block */}
failure: ^(NSError *error){/* Code Block */}
];
setDevelopmentMode
Enables development mode logs requests/responses to console.
Method Signature:
(void)setDevelopmentMode: (BOOL)flag;
Arguments:
flag:
If true enables development mode.
Usage:
[CometChat setDevelopmentMode: YES];
isTyping
Sends the typing notification.
Method Signature:
(void)isTyping: (BOOL)flag
channel: (NSString *)channel;
Arguments:
flag:
This is BOOL value, pass YES when you start typing, pass NO when you stop typing.
toUser:
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. The datatype is NSString.
Usage:
[cometChat isTyping: YES
channel: buddyChannel
];
Or
[cometChat isTyping: NO
channel: buddyChannel
];
isLoggedIn
Checks if the user is logged-in
Method Signature:
(BOOL)isLoggedIn;
Usage:
[CometChat isLoggedIn];
unsubscribe
Unsubscribes CometChat and stops receiving responses from the server.
Method Signature:
(void)unsubscribe;
Arguments:
videoPath:
The path of the video file to be sent as NSString datatype.
toUser:
The userid of a user to whom the video is being sent.
Usage:
[cometchat unsubscribe];
Please refer error codes for failure responses.