Browse SDKs · iOS
Platform
SDKsiOSEnterprise

Retrieve pinned messages

Retrieve a snapshot of pinned messages in a conversation with OpenIM iOS SDK.

Copy

Invoke getConversationPinnedMsgWithConversationID:onSuccess:onFailure: on OIMManager to retrieve a list of currently pinned messages in a specified conversation:

Parameters

ParameterTypeRequiredDescription
conversationIDNSString *YesTarget conversation identifier.
onSuccessvoid (^)(NSArray<OIMMessageInfo *> * _Nullable messages)YesSuccess callback returning an array of pinned message models.
onFailureOIMFailureCallbackYesFailure callback returning error code code and descriptive message msg.

Code example

[[OIMManager manager] getConversationPinnedMsgWithConversationID:conversationID
                                                       onSuccess:^(NSArray<OIMMessageInfo *> * _Nullable messages) {
    // Render or refresh the pinned messages banner at the top of the conversation view
    [self replacePinnedMessages:messages ?: @[] conversationID:conversationID];
}
                                                       onFailure:^(NSInteger code, NSString * _Nullable msg) {
    // Handle query failure
}];

Return value

The onSuccess callback delivers an array of OIMMessageInfo models representing pinned messages. The array contains message entities only, without pin timestamps or operator metadata.

State changes after the call

  1. Snapshot querying: This query establishes an instantaneous snapshot of pinned messages and does not trigger pin event listeners.
  2. Client merge key: The merge key is clientMsgID scoped to conversationID.
  3. Live updates: Real-time additions or removals of pinned messages are delivered via the listener documented in Pin or unpin a message.