The Methods below are available for Group chat:
Method | Description |
---|---|
createGroup | Allows logged-in user to create a group |
renameGroup | Allows Group Creator or Moderator to rename the group |
inviteUser | Allows logged-in user to invite other user to the group |
joinGroup | Allows logged-in user to join a group |
getGroupMembers | Gets list of the Group Members |
getAllGroup | Gets list of all the groups accessible to currently opened group chat |
sendMessage | Allows logged-in user to send a message to currently opened group chat |
sendImage | Allows logged-in user to send an image to currently opened group chat |
sendVideo | Allows logged-in user to send a video to currently opened group chat |
sendAudioFile | Allows logged-in user to send an audio file to currently opened group chat |
sendSticker | Allows logged-in user to send a sticker to currently opened group chat |
sendFile | Allows logged-in user to send a file to the group |
getGroupHistory | Gets the previous messages in currently opened group chat |
getCurrentGroup | Gets the id of in currently opened group chat |
leaveGroup | Allows logged-in user to leave currently opened group chat |
deleteGroup | Allows logged-in user to delete a group if he is creator or moderator of the group |
createGroup
Allows logged-in user to create a group Method Signature:
public virtual void createGroup(
string name,
nint type,
string password,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.createGroup("Targaryen",PUBLIC_GROUP,""
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
name | Name of the group |
password | Password for password-protected group |
type | 1 indicates public group and 2 indecates password-protected group |
callback | Success and failure callback |
Response for successCallback:
{
group_id: 7
}
Description:
Response Property | Description |
---|---|
group_id | id of the created group |
renameGroup
Allows Group Creator or Moderator to rename the group Method Signature:
public virtual void renameGroup(
string groupId,
string groupName,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.renameGroup("5","White Walkers"
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
groupId | id of the group to rename |
groupname | New name for the group |
callback | success and failure callback |
Response for successCallback:
{
group_id: 5
}
inviteUsers
Allows logged-in user to invite other user to the group Method Signature:
public virtual void inviteUser(
NSObject[] userArray,
string groupName,
string groupId,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.inviteUser(userArray,"Starks","15"
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
usersArray | JSONArray containing id of the users to invite |
groupName | group name in which user is invited |
groupId | group id in which user is invited |
callback | failure callbacks |
Response for successCallback:
{
group_id: 15
}
Description:
Response Property | Description |
---|---|
group_id | id of the deleted group |
joinGroup
Allows logged-in user to join a group
public virtual void joinGroup(
string name,
string groupId,
string password,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.joinGroup(userArray,"Starks","5","",
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Agruments:
Argument | Description |
---|---|
groupId | id of a group to join |
name | name of the group to join |
groupPassword | password for password-protected group |
callback | success and failure callbacks |
Response for successCallback:
{
"group_id": "5",
"push_channel": "C_c49602157105d9d6383bb30695f771e8"
}
Description:
Response Property | Description |
---|---|
group_id | id of the joined group |
push_channel | a unique channel to receive the mobile push notification for the joined group |
getAllGroup
Gets list of all the groups accessible to currently opened group chat Method Signature:
public virtual void getAllGroups(
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.getAllGroups(
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
callback | success and failure callbacks |
Response for successCallback:
{
"_4":{
"id":"4", "name":"group1", "online":"1", "type":"0", "i":"", "s":0
},
"_2":{
"id":"2", "name":"group2", "online":"0", "type":"0","i":"","s":0
}
}
Description:
Response Property | Description |
---|---|
id | id of a group |
name | name of a group |
online | number of group participants |
type | type of a group. 1 indicates public group |
i | represents password for password protected group |
s | 1 indicates Owner, 2 indicates Moderator and 0 Indicates logged-in user is neither Owner nor Moderator for the group |
leaveGroup
Allows logged-in user to leave currently opened group chat Method Signature:
public virtual void LeaveGroup(
NSDictionary leaveGroupParameter,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.LeaveGroup(leaveGroupDict,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
currentroom | id of the group to be left |
callback | success and failure callbacks |
deleteGroup
Allows logged-in user to delete a group if he is creator or moderator of the group Method Signature:
public virtual void deleteGroup(
string groupId,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.deleteGroup("15",
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
groupId | id of a group to delete |
callback | success and failure callbacks |
Response for successCallback:
{
group_id: 15
}
Description:
Response Property | Description |
---|---|
group_id | id of the deleted group |
sendMessage
Allows logged-in user to send message to other users. Method Signature:
public virtual void sendMessage(
string message,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendMessage("Hi! How are you?","15","71",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
localID | a parameter which is returned to you with the response to keep track of the status of the message sent |
toId | recipient’s user id |
message | text message |
isGroup | is recipient group or user |
callback | success and failure callbacks |
Response for successCallback:
{
"id": 71,
"localmessageid":100,
"m": "Hi! How are you?"
}
Description:
Response type | Description |
---|---|
id | id of the message |
m | The message received from the server |
sendImage
Allows logged-in user to send an image using Bitmap or filepath Method Signature:
public virtual void sendImageWithData(
NSData imageData,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendImageWithData(imageData,"15","50",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
localID | A unique value that is returned to you in the response to keep track of the status of the message |
imageData | NSData of the image |
toId | recipient’s user id |
isGroup | is recipient group or user |
callback | success and failure callbacks |
Response for successCallback:
{
"id": 23,
"localmessageid" : 101,
"original_file": "/Documents/IMG1049.JPG"
}
sendVideo
Allows logged-in user to send a video Method Signature:
public virtual void sendVideoWithPath(
string videoPath,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendVideoWithPath("/Documents/Video.mp4","15","50",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
localID | A unique value that is returned to you in the response to keep track of the status of the message |
videoPath | path of the file |
toId | recipient’s user id |
isGroup | is recipient group or user |
callback | success and failure callbacks |
Response for successCallback:
{
"id": 23,
"localmessageid:102,
"original_file": "/Documents/Video.mp4"
}
sendAudioFile
Allows logged-in user to send an audio file or recorded audio notes Method Signature:
public virtual void sendAudioWithPath(
string audioPath,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendAudioWithPath("/Documents/audio1.aac","15","50",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
localId | A unique value that is returned to you in the response to keep track of the status of the message |
audioPath | audio file from storage |
toId | recipient’s user id |
isGroup | is recipient group or user |
callback | success and failure callbacks |
Response for successCallback:
{
"id": 23,
"localmessageid" : 104,
"original_file": "/Documents/audio1.aac"
}
sendSticker
Allows the user to send a sticker.
Method signature:
public virtual void sendStickers(
string stickerName,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendStickers("bear_1","15","501",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Arguments:
Argument | Description |
---|---|
localID | A unique value that is returned to you in the response to keep track of the status of the message |
stickerName | Sticker name |
toId | recipient’s user id |
isGroup | is recipient group or user |
callback | success and failure callbacks |
sendFile
Allows the logged in user to send a file to a group.
Method Signature:
public virtual void sendFile(
string filePath,
string toId,
string localID,
Bool isGroup,
Action < NSDictionary > response,
Action < NSError> failure
)
Example:
cometchat.sendFile("Path of File To Be Sent","15","501",true,
(dict) => { this.response(dict); /* code block */ },
(err) => { this.failure(err); /* code block */ }
);
Argument | Description |
---|---|
localId | A unique value that is returned to you in the response to keep track of the status of the message |
filePath | file to be sent |
toId | recipient’s user id |
isGroup | is recipient group or user |
callback | success and failure callbacks |