SDKsiOSEnterprise
Add conversations to groups
Add conversation-group relationships with Open_im_sdkAddConversationsToGroups.
Invoke Open_im_sdkAddConversationsToGroups to associate one or more conversations with specified conversation groups in a batch. This operation establishes group associations only; it does not alter conversation data or message delivery:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
conversationIDs | NSArray<NSString *> * | Yes | List of conversation IDs to add into the groups. |
conversationGroupIDs | NSArray<NSString *> * | Yes | List of target conversation group IDs. |
Code example
#import <OpenIMSDK/CallbackProxy.h>
@import OpenIMCore;
NSData *conversationData =
[NSJSONSerialization dataWithJSONObject:@[@"c2c_user1002"] options:0 error:nil];
NSString *conversationIDsJSON =
[[NSString alloc] initWithData:conversationData encoding:NSUTF8StringEncoding];
NSData *groupData =
[NSJSONSerialization dataWithJSONObject:@[@"group_work_101"] options:0 error:nil];
NSString *groupIDsJSON =
[[NSString alloc] initWithData:groupData encoding:NSUTF8StringEncoding];
CallbackProxy *callback = [[CallbackProxy alloc]
initWithOnSuccess:^(NSString * _Nullable data) {
NSLog(@"AddConversationsToGroups success");
}
onFailure:^(NSInteger code, NSString * _Nullable message) {
NSLog(@"AddConversationsToGroups failed: %ld %@", (long)code, message);
}];
Open_im_sdkAddConversationsToGroups(callback, conversationIDsJSON, groupIDsJSON);Return value
The onSuccess callback returns confirmation when the association request completes successfully.
State changes after the call
- Local state update: The client updates local membership records keyed by composite identifiers (
conversationGroupIDandconversationID). - Event notification: Active client sessions receive notifications through the
onConversationGroupMemberAdded:listener callback. - Re-query calibration: For listener integration details, refer to Conversation groups overview.
Was this page helpful?