Browse SDKs · iOS
Platform
SDKsiOSIncludes Enterprise features

Events overview

Register OpenIM iOS SDK listeners and synchronize connection and data state with the application lifecycle.

Copy

The OpenIM iOS SDK defines listener protocols segmented by functional domain. Add and remove listeners through [OIMManager callbacker]. Retain a strong reference to each listener instance within your application state management layer, as OIMCallbacker maintains only weak references to registered delegates.

Registration lifecycle

Event scopeProtocolRelated documentation
Connection and tokenConnection callbacks passed during initializationAuthenticate and manage the session
User, friend, and blacklistOIMUserListener, OIMFriendshipListenerUser overview
Conversations and synchronizationOIMConversationListenerRetrieve the conversation list
Conversation groupsOpen_im_sdk_callbackOnConversationGroupListenerConversation groups overview
Groups and group membersOIMGroupListenerGroup overview
MessagesOIMAdvancedMsgListenerReceive messages
Custom business notificationsOIMCustomBusinessListenerReceive custom business messages
Audio and video callsOIMSignalingListenerHandle call events

Register application-level listeners after initSDKWithConfig:... succeeds and prior to initiating login:token:.... Avoid re-registering listeners on view transition or rendering cycles. When logging out, switching user accounts, or tearing down the state controller, invoke the matching remove...Listener: method with the retained listener instance.

Conversation group events follow a dedicated mechanism: OpenIMCore configures a single Open_im_sdk_callbackOnConversationGroupListener via Open_im_sdkSetConversationGroupListenerEnterprise. It bypasses [OIMManager callbacker] and cannot be registered incrementally. Retain this callback object within the conversation manager for the duration of the session and configure it once during startup. Refer to Conversation groups overview for detailed JSON payloads and callback contracts.

Listen for initial synchronization

Data synchronization lifecycle callbacks reside within the OIMConversationListener protocol. Implement the four core synchronization methods to track server state synchronization:

Code example

@interface SDKSyncStore () <OIMConversationListener>
@end

@implementation SDKSyncStore

- (void)startListening {
    [[OIMManager callbacker] addConversationListener:self];
}

- (void)stopListening {
    [[OIMManager callbacker] removeConversationListener:self];
}

- (void)onSyncServerStart:(BOOL)reInstall {
    [self setSyncingWithProgress:0 reInstall:reInstall];
}

- (void)onSyncServerProgress:(NSInteger)progress {
    [self setSyncingWithProgress:progress reInstall:self.reInstallSync];
}

- (void)onSyncServerFinish:(BOOL)reInstall {
    [self setSyncReadyWithReInstall:reInstall];
    [self reloadVisibleSnapshots];
}

- (void)onSyncServerFailed:(BOOL)reInstall {
    [self setSyncFailedWithReInstall:reInstall];
}

@end

When reInstall evaluates to YES, synchronization follows a local database rebuild, indicating that complete state restoration is underway. Track synchronization progress with onSyncServerProgress:. Once synchronization finishes, re-query initial data snapshots required by visible views, and subsequently process incremental updates dispatched by domain listeners.

Synchronization events operate independently of query API callbacks and carry no business entity merge keys. Process synchronization completion, query snapshot fetching, and subsequent real-time event merges as distinct operational phases, scoping data strictly by user account.