logo
In-app Chat
SDK Error Codes
On this page

Message pinned to top


Introduction

Note

To use this feature, please subscribe to the Enterprise plan.

ZIM SDK supports adding specific messages to the pinned message list in a conversation, and conversation members can query messages in the pinned message list at any time. This feature can be used to pin important messages at the top of the conversation for quick viewing by conversation members.

Listen for message pinned status changes

Conversation members register setEventHandler to listen for messagePinStatusChanged callbacks to receive notifications of message pinned status changes. When other users pin messages, they can obtain information such as the status change, pinned time, and pinned operator of the pinned messages through this notification.

Sample code
// Register event
- (void)zim:(ZIM *)zim messagePinStatusChanged:(NSArray<ZIMMessagePinStatusChangeInfo *> *)changeInfoList {
    if (zim != self.zim) {
        return;
    }
    // When the message pinned status changes, the pinned message/unpinned message can be obtained here to refresh the UI
};

Pinned messages

Conversation members can call pinMessage to pin messages sent successfully in a conversation. The supported message types are as follows:

Message typeDescription
ZIMTextMessageText message
ZIMMultipleMessageMultiple message
ZIMImageMessageImage message
ZIMFileMessageFile message
ZIMAudioMessageAudio message
ZIMVideoMessageVideo message
ZIMCombineMessageCombined message
ZIMCustomMessageCustom message

After a message is pinned, the result of the pinned operation can be obtained through ZIMMessagePinnedCallback interface. When there is a pinned message in a conversation, conversation members can call queryPinnedMessageListByConversationID to query the pinned message, and obtain the pinned message list through ZIMPinnedMessageListQueriedCallback .

Warning
  • Message pinned to top only supports calling in one-on-one and group chat conversations.
  • Each conversation only supports supporting up to ten messages. When trying to pin the eleventh message, the message with the earliest pinned time will be automatically unpinned.
  • Repeating the pinning of the same message will update its pinned time.
  • The pinnedUserID and pinnedTime fields in the ZIMMessage message object are only returned in ZIMPinnedMessageListQueriedCallback and messagePinStatusChanged .
  • Whether group pinned/unpinned actions trigger group Tips messages can be configured in the backend (by default, push is not enabled). When the push is enabled, if a message in a group chat is pinned or unpinned, group members will receive a related pinned message Tips notification, such as: "XXX pinned a message to the top". For more information, see Receive tip messages.
Sample code
// Pin a text message
ZIMTextMessage *messageObj; // Get from queryHistoryMessage interface

[[ZIM getInstance] pinMessage:messageObj 
                     isPinned:YES 
                    callback:^(ZIMError * _Nonnull errorInfo) {
    // Get the result of the pinned message operation from here
}];

[[ZIM getInstance] queryPinnedMessageListByConversationID:conversationID 
                                         conversationType:conversationType 
                                                 callback:^(NSArray<ZIMMessage *> * _Nonnull messageList, ZIMError * _Nonnull errorInfo) {
    // Get the pinned message list from here
}];

Previous

Respond to messages with emoticons

Next

Export and import messages

On this page

Back to top