GroupChat

To add Group Chat support in your app,

Include the class in the <MessageSDKFramework/GroupChat.h> file of your class.

Initialize GroupChat object

GroupChat *groupchat =  [[GroupChat alloc] init];

Methods available:

Method Description
subscribeToGroupChatWithMode The method starts receiving groups list, members list, and group chat messages
createGroup The method allows you to create a group
joinGroup The method allows you to send an image
inviteUsers The method allows you to invite a user to group
sendGroupChatMessage The method allows you to send audio file
sendImageWithData The method allows you to send an image with image data
sendimagewithpath The method allows you to send an image with path
sendAudioWithPath The method allows you to send an audio file using its physical path
sendVideoWithPath The method allows you to send a video file using its physical path
sendVideoWithURL The method allows you to send a video file using its URL
sendFileWithPath The method allows you to send a file
leaveGroup The method allows you to leave a group
getAllGroups The method allows get details of all the groups
deleteGroup The method allows you to delete a group
renameGroup The method allows you to rename a group
getGroupMembers The method allows you to get list of users in a group
isSubscribedToGroup The method allows you to check if the logged-in user is a member of a group
unsubscribeFromGroupChat The method allows you to unsubscribe the group

subscribeToGroupChatWithMode

The method starts receiving group lists and group messages
Method Signature:

  (void)subscribeToGroupChatWithMode: (BOOL)mode
          onGroupChatMessageReceived: (void(^)(NSDictionary *response))message
             onActionMessageReceived: (void(^)(NSDictionary *response))actionMessage
                 onGroupListReceived: (void(^)(NSDictionary *response))groupList
             onAVChatMessageReceived: (void(^)(NSDictionary *response))avchatMessage
                             failure: (void(^)(NSError *error))failure;

Arguments:

mode:

mode is a boolean flag. If set to true, allows emoji in text messages.

onGroupChatMessageReceived

onGroupChatMessageReceived 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. The field message_type indicates the type of received message.

Types of messages received in this callback:

Message Type Description
10 Text message
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:

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "12";
    "message" = "Hello";
    "sent" = 1415082627474;
    "message_type" = 10;
}

b. Image file in a message

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "13";
    "message" = "http://yoursite.com/cometchat/plugins/filetransfer/download.phpfile=a1d28da22369e330fab64e0250226
                d0b.png&unencryptedfilename=Image.png";
    "sent" = 1411035424323;
    "message_type" = 12;
}

c. Image sent through Handwrite plugin

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "14";
    "message" = "http://yoursite.com/cometchat/plugins/handwrite/uploads/9384627441b49aad5ef6bace29cdcd36.png";
    "sent" = 1411035443457;
    "message_type" = 13;
}

d. Video file in a message

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "15";
    "message" = "http://yoursite.com/cometchat/plugins/filetransfer/download.php?file=a1d28da22369e330fab64e0250226d
                0b.pngunencryptedfilename=Video.mp4";
    "sent" = 1411035498654;
    "message_type" = 14;
}

e. Audio file in a message

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "16";
    "message" = "http://yoursite.com/cometchat/plugins/filetransfer/download.php?file=a1d28da22369e330fab64e0250226
                d0b.png&unencryptedfilename=sample.mp3";
    "sent" = 1411031245637;
    "message_type" = 17;
}

f. File other than audio, video or image in a message

{
    "from" = "test-9";
    "fromid" = 9;
    "id" = "17";
    "message" = "http://yoursite.com/cometchat/plugins/filetransfer/download.php?file=a1d28da22369e330fab64e0250226
                d0b.png&unencryptedfilename=samplefile.txt";
    "sent" = 1411065498732;
    "message_type" = 18;
}

h. Bot Responses:
Bot can respond with text, image or anchor(hyperlink).
Bot response : Text

{
    "bot_id" = 32;
    "bot_response_type" = text;
    from = Me;
    fromid = 100;
    id = 1102;
    message = "You said test";
    "message_type" = 24;
    groupid = 34;
    sent = 1482406766;
}

Bot response : Image

{
    "bot_id" = 30;
    "bot_response_type" = image;
    from = Me;
    fromid = 100;
    id = 1104;
    message = "http://i.giphy.com/l2YWjLlllAFOkog9i.gif";
    "message_type" = 24;
    groupid = 34;
    sent = 1482406818;
}

Bot response : Anchor

{
    "bot_id" = 33;
    "bot_response_type" = anchor;
    from = Me;
    fromid = 100;
    id = 1106;
    message = "hi this is a test message!<br><a href=\"https://app.bots.co/components/add/1164\">bots</a>";
    "message_type" = 24;
    groupid = 34;
    sent = 1482406911;
}

onActionMessageReceived

onActionMessageReceived is a callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))actionMessage
Invocation: Invoked when user gets action messages for a group. Action messages are distinguished by the key ‘action_type’
Response: NSDictionary containing action type and group id. Incase of DELETE_GROUPCHAT_MESSAGE_ACTION, message id is received instead of group id.

Sample Response:

KICK_ACTION

 {
   "action_type" = "10";
   "group_id" = "5";
 }

BAN_ACTION

 {
   "action_type" = "11";
   "group_id" = "5";
 }

DELETE_GROUPCHAT_ACTION

 {
   "action_type" = "12";
   "group_id" = "5";
 }

DELETE_GROUPCHAT_MESSAGE_ACTION

 {
   "action_type" = "10";
   "message_id" = "45";
 }

onGroupListReceived

onGroupListReceived is a callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))groupList
Invocation: When the server send list of the groups
Response: NSDictionary containing the list of the groups.

Sample Response:

{
    "_4" = {
        "id" = "4";
        "name" = "group1";
        "online" = "1",
        "type" = "0";
        "i" = "";
        "s" = 0;
    },
    "_2" = {
        "id" = "2";
        "name" = "group2";
        "online" = "0";
        "type" = "0";
        "i" = "";
        "s" = 0;
    }
}

onAVChatMessageReceived

onAVChatMessageReceived is a callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))avchatMessage
Invocation: When an audio video conference message is received
Response: NSDictionary containing audio video group conference messages and its details

Sample Response:

{
    "to" = 105;
    "id" = "64";
    "message" = "HAS STARTED A VIDEO CONVERSATION";
    "self" = 0;
    "old" = "1";
    "sent" = 1411035449792;
    "from" = "73";
    "message_type" = "32";
}

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 subscribeToGroupChatWithMode: YES 
             onGroupChatMessageReceived: ^(NSDictionary *response){/* Code Block */}
                onActionMessageReceived: ^(NSDictionary *response){/* Code Block */}
                    onGroupListReceived: ^(NSDictionary *response){/* Code Block */}
                onAVChatMessageReceived: ^(NSDictionary *response){/* Code Block */}
                                failure: ^(NSError *error){/* Code Block */}
];

createGroup

Allows user to create a group and makes him/her automatically joins the group.

Method Signature:

(void)createGroup: (NSString *)groupName
           OfType: (NSInteger)type 
     withPassword: (NSString *)groupPassword
          success: (void(^)(NSDictionary *response))success
          failure: (void(^)(NSError *error))failure;

Arguments:

groupName:

Name of the group as NSString datatype.

OfType:

Type of group as NSInteger datatype, 1 for public groups and 2 for password protected group

groupPassword:

Password for the password protected groups as NSString datatype. For non-password protected group keep it as empty string.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: When group is created successfully
Response: NSDictionary containing the group ID of newly created group

Sample Response:

{
   group_id: 5;
}

failure

A callback Method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there’s an error while creating a group
Response: NSError containing error code and message

Usage:

[groupchat createGroup: @"Friends" 
                OfType: PUBLIC_GROUP 
          withPassword: @"" 
               success: ^(NSDictionary *response){/* Code Block */}
               failure: ^(NSError *error){/* Code Block */}
];

joinGroup

Allows user to join a group.

Method Signature:

    (void)joinGroup: (NSString *)groupName 
            groupID: (NSString*)groupID 
      groupPassword: (NSString *)groupPassword
            success: (void(^)(NSDictionary *response))success
            failure: (void(^)(NSError *error))failure;

Arguments:

groupName:

Name of the group as NSString datatype.

groupID:

Id of the group as NSString datatype.

groupPassword:

The password (if any) should be SHA-1 encoded as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: Invoked when the logged in user has entered a group
Response: NSDictionary containing ID and push notification channel of the joined group

Sample Response:

{
    group_id= "5";
    push_channel= "C_c49602157105d9d6383bb30695f771e8";
}

failure

A callback Method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there’s an error while joining a group
Response: NSError containing error code and message

Usage:

[groupchat joinGroup: @"Friends" 
             groupID: @"6" 
       groupPassword: @""
             success: ^(NSDictionary *response){/* Code Block */}
             failure: ^(NSError *error){/* Code Block */}
];

inviteUsers

Allows user to invite other users to a group. All the invited users will receive join group message with message_type=11 in onMessageReceived callback of subscribeWithMode method of CometChat class

Method Signature:

    (void)inviteUsers: (NSArray *)usersID
              toGroup: (NSString *)groupName
          withGroupID: (NSString *)groupID
              success: (void(^)(NSDictionary *))success
              failure: (void(^)(NSError *error))failure;

Arguments:

usersID:

The userids of the users to be invited to the group as NSArray of NSString datatype.

groupName:

Name of the group as NSString datatype.

groupID:

Id of the group as NSString datatype.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: Invoked when the users are invited successfully to the group
Response: NSDictionary containing ID of the successfully invited users

Sample Response:

{
   [email protected][@"3",@"33",@"23"];
}

failure

A callback Method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there’s an error while inviting users to a group
Response: NSError containing error code and message

Usage:

[groupchat inviteUsers: @[@"3",@"33",@"23"]
               toGroup: @"Friends"
           withGroupID: @"6"
               success: ^(NSDictionary *response){/* Code Block */} 
               failure: ^(NSError *error){/* Code Block */}
];

sendGroupChatMessage

Sends text/emoji message to a group.

Method Signature:

 (void)sendGroupChatMessage: (NSString *)message
                    toGroup: (NSString *)groupName
                withGroupID: (NSString *)groupID
                withsuccess: (void (^)(NSDictionary *response))response
                    failure: (void (^)(NSError *))failure;

Arguments:

message:

The text message to be sent as NSString datatype.

groupName:

Name of the group as NSString datatype.

groupID:

Id of the group as NSString datatype.

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" = "703";
    "m" = "Good Day to All!!!";
}

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:

[groupchat sendGroupChatMessage: @"Good Day to All!!!"
                        toGroup: @"Friends"
                    withGroupID: @"6"
                    withsuccess: ^(NSDictionary *response){/* Code Block */}
                        failure: ^(NSError *error){/* Code Block */}
];

sendImageWithData

Sends image with image data.
Method Signature:

 (void)sendImageWithData: (NSData *)imageData 
                 toGroup:(NSString *)groupName
             withGroupID:(NSString *)groupID
                 success: (void(^)(NSDictionary *response))response
                 failure: (void(^)(NSError *error))failure;

Arguments:

imageData :

The image data to be sent as NSData datatype.

toGroup:

The name of the group to whom the image is being sent.

withGroupID:

The id of the group 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" = "72";
    "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
                     toGroup: @"Friends"
                 withGroupID: @"6" 
                     success: ^(NSDictionary *response){/* Code Block */}
                     failure: ^(NSError *error){/* Code Block */}
];

sendImageWithPath

Sends image at given path.
Method Signature:

 (void)sendImageWithPath: (NSString *)sendImageWithPath
                 toGroup: (NSString *)groupName
             withGroupID: (NSString *)groupID
                 success: (void(^)(NSDictionary *response))response
                 failure: (void(^)(NSError *error))failure;

Arguments:

imagePath:

The path of the image to be sent as NSString datatype.

toGroup:

The name of a group to which the image is being sent.

withGroupID:

The userid a group to which 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" = "72341";
    "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"
                     toGroup: @"Friends"
                 withGroupID: @"6"
                     success: ^(NSDictionary *response){/* Code Block */}
                     failure: ^(NSError *error) {/* Code Block */}
];

sendAudioWithPath

Sends an audio file at given path to another user.
Method Signature:

 (void)sendAudioWithPath: (NSString *)audioPath
                 toGroup: (NSString *)groupName
             withGroupID: (NSString *)groupID
                 success: (void(^)(NSDictionary *response))response
                 failure: (void(^)(NSError *error))failure;

Arguments:

audioPath:

The path of the audio file to be sent as NSString datatype.

toGroup:

The name of a group to which the audio file is being sent.

withGroupID:

The userid a group to which the audio file 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 audio file 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"
                     toGroup: @"Friends" 
             withGroupID: @"6"
                     success: ^(NSDictionary *response){/* Code Block */}
                     failure: ^(NSError *error){/* Code Block */}
];

sendVideoWithPath

Sends video from given path
Method Signature:

 (void)sendVideoWithPath: (NSString *)videoPath
                 toGroup: (NSString *)groupName
             withGroupID: (NSString *)groupID
                 success: (void(^)(NSDictionary *response))response
                 failure: (void(^)(NSError *error))failure;

Arguments:

videoPath:

toGroup:

The name of a group to which the video is being sent.

withGroupID:

The userid a group to which 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"   
                     toGroup: @"Friends" 
                 withGroupID: @"6"
                     success: ^(NSDictionary *response){/* Code Block */}
                     failure: ^(NSError *error){/* Code Block */}           
];

sendVideoWithURL

Sends video using NSURL
Method Signature:

 (void)sendVideoWithURL: (NSURL *)videoURL
                toGroup: (NSString *)groupName
            withGroupID: (NSString *)groupID
                success: (void(^)(NSDictionary*response))response
                failure: (void(^)(NSError *error))failure;

Arguments:

videoURL:

The path of the video file to be sent as NSURL datatype.

toGroup:

The name of a group to which the image is being sent.

withGroupID:

The userid a group to which the image 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 
                    toGroup: @"Friends" 
                withGroupID: @"6"
                    success: ^(NSDictionary *response){/* Code Block */}
                    failure: ^(NSError *error){/* Code Block */}           
];

sendFileWithPath

Sends file from given path
Method Signature:

 (void)sendFileWithPath: (NSString *)filePath 
                toGroup: (NSString *)groupName
            withGroupID: (NSString *)groupID
                success: (void(^)(NSDictionary *response))response
                failure: (void(^)(NSError *error))failure;

Arguments:

filePath:

The path of the file to be sent as NSString datatype.

toGroup:

The name of a group to which the file is being sent.

withGroupID:

The userid a group to which the file 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"   
                    toGroup: @"Friends" 
                withGroupID: @"6"
                    success: ^(NSDictionary *response){/* Code Block */}
                    failure: ^(NSError *error){/* Code Block */}
];

leaveGroup

Allows user to leave a group
Method Signature:

  (void)leaveGroup: (NSString *)groupID
           success: (void(^)(NSDictionary *response))response
           failure: (void(^)(NSError *error))failure;

Arguments:

groupID:

The id of the group to leave.

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: After successfully leaving the group
Response: NSDictionary containing the group id of left group

Sample Response:

{
    "group_id" = 6;
}

failure

A callback method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there is an error while leaving group
Response: NSError containing error code

Usage:

[cometchat getUserInfo: @"6"
               success: ^(NSDictionary *response){/* Code Block */}
               failure: ^(NSError *error){/* Code Block */}
];

getAllGroups

Fetches the list of all groups associated with logged-in user
Method Signature:

  (void)getAllGroups: (void(^)(NSDictionary *groupList))response
             failure: (void(^)(NSError *error))failure;

Arguments:

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *groupList))response
Invocation: When group list is received successfully.
Response: NSDictionary containing the group list

Sample Response:

{
  "_4"={
    "id"="4";
    "name"="group1";
    "online"="1";
    "type"="0";
    "i"="";
    "s"=0;
  },
  "_2"={
    "id"="2";
    "name"="group2";
    "online"="0";
    "type"="0";
    "i"="";
    "s"=0;
  }
}

failure

A callback method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there is an error while fetching list of groups
Response: NSError containing error code

Usage:

[cometchat changeStatus: STATUS_AVAILABLE
                success: ^(NSDictionary *response){/* Code Block */}
                failure: ^(NSError *error){/* Code Block */}
];

deleteGroup

Deletes a group
Method Signature:

  (void)deleteGroup: (NSString *)groupID
            success: (void(^)(NSDictionary *response))response
            failure: (void(^)(NSError *error))error;

Arguments:

groupID:

The id of the group to delete

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: When group is deleted successfully
Response: NSDictionary containing the group id of deleted group

Sample Response:

{
     group_id = 5;
}

failure

A callback method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there is an error while deleting a group
Response: NSError containing error code

Usage:

[cometchat deleteGroup: @"5" 
               success: ^(NSDictionary *response){/* Code Block */}
               failure: ^(NSError *error){/* Code Block */}
];

renameGroup

Renames a group
Method Signature:

  (void)renameGroup: (NSString *)groupID
            toGroup: (NSString *)groupName
            success: (void(^)(NSDictionary *response))response
            failure: (void(^)(NSError *error))error;

Arguments:

groupID:

The id of the group to rename as NSString

toGroup

The new name for the group as NSString

success

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: When group is renamed successfully
Response: NSDictionary containing the group id of the renamed group

Sample Response:

{
     group_id = 5;
}

failure

A callback method.

Method Property Description
Method Signature: (void(^)(NSError *error))failure
Invocation: If there is an error while renaming a group
Response: NSError containing error code

Usage:

[groupchat renameGroup: @"6"
               toGroup: @"Friends Forever" 
               success: ^(NSDictionary *response){/* Code Block */}
               failure: ^(NSError *error){/* Code Block */}
];

getGroupMembers

Gets the list of currently active users
Method Signature:

(void)getGroupMembers: (NSString *)groupId
              success: (void (^)(NSDictionary *))success
              failure: (void (^)(NSError *))failure;

Arguments:

groupId

The id of the group which members list is needed.

response

A callback method.

Method Property Description
Method Signature: (void(^)(NSDictionary *response))response
Invocation: When list members of a group is received
Response: NSDictionary containing the list members of a group

Sample Response:

{
    "_102" = {
        "id" = "102";
        "n" = "test-102";
        "a" = "img.png";
        "b" = "0";
    },
    "_73" = {
        "id" = "73";
        "n" = "test-73";
        "a" = "img.png";
        "b" = "0";
    }
}

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 getGroupMembers: @"6"
                   suceess: ^(NSDictionary *response){/* Code Block */}
                   failure: ^(NSError *error){/* Code Block */}
];

isSubscribedToGroup

Checks if the logged-in user is a member of a group
Method Signature:

(BOOL)isSubscribedToGroup: (NSString *)groupID;

Arguments:

groupID:

The id of the group
Usage:

[GroupChat isSubscribedToGroup:@"2"];

unsubscribeFromGroupChat

Stops receiving groupchat messages, user’s list and group updates. Also, logged-in user will be exited from currently joined group (if any).
Method Signature:

 (void)unsubscribeFromGroupChat; 

Usage:

[groupchat unsubscribeFromGroupChat];

Please refer ‎error codes for failure responses.

  • Was this helpful?
  • Yes   No