Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Conversation groups overview

Understand conversation-group data boundaries and listener lifecycle in OpenIM iOS SDK.

Copy

Conversation groups categorize and organize the signed-in user's conversation list. They manage relationships between conversationID values and custom groups, without creating chat groups, modifying member lists, or changing message delivery targets.

The iOS SDK exposes conversation-group capabilities through OpenIMCore Objective-C functions distributed with OpenIMSDK; they are not yet wrapped in high-level OIMManager model classes. Requests, results, and listener payloads are JSON NSString values. Parse them using NSJSONSerialization rather than declaring custom model classes.

Group types

ValueMeaning
0Regular custom group, created and managed manually by the user.
1Rule-filtered group, maintained automatically by server or SDK rules.
2All group types, used strictly as a query filter parameter and not for group creation.

Use type 0 for user-defined categories. The generation rules for filtered groups depend on backend configuration.

Available operations

Set the conversation-group listener

Open_im_sdkSetConversationGroupListener maintains a single active Open_im_sdk_callbackOnConversationGroupListener instance. Because there is no separate unregister function, retain the listener within an account-scoped manager and initialize it once during session startup.

#import <OpenIMSDK/CallbackProxy.h>
@import OpenIMCore;

@interface ConversationGroupStore () <Open_im_sdk_callbackOnConversationGroupListener>
@end

@implementation ConversationGroupStore

- (void)startListening {
    Open_im_sdkSetConversationGroupListener(self);
}

- (void)onConversationGroupAdded:(NSString * _Nullable)json {
    [self mergeConversationGroupsJSON:json];
}

- (void)onConversationGroupChanged:(NSString * _Nullable)json {
    [self mergeConversationGroupsJSON:json];
}

- (void)onConversationGroupDeleted:(NSString * _Nullable)json {
    [self removeConversationGroupsJSON:json];
}

- (void)onConversationGroupMemberAdded:(NSString * _Nullable)json {
    [self mergeConversationGroupMembersJSON:json];
}

- (void)onConversationGroupMemberDeleted:(NSString * _Nullable)json {
    [self removeConversationGroupMembersJSON:json];
}

@end

The group added, changed, and deleted callbacks pass JSON arrays of groups. Member modification callbacks provide JSON containing group, conversationIDs, and conversations. Merge group state using conversationGroupID as the primary key, and identify member associations using composite keys of conversationGroupID and conversationID.

When switching accounts, stop the active listener from dispatching to UI components and register the new account's listener. Method execution completion, listener event delivery, and cache calibration queries are three distinct stages.