/ SDKs / iOS
SDKs
Chat SDKs iOS v4
Chat SDKs iOS
Chat SDKs
iOS
Version 4

Pin a message

Copy link

Sendbird Chat SDK for iOS allows you to pin messages in group channels. You can pin all types of messages including text message, file message, multiple file message, and admin message. The pinned messages feature allows users to mark or highlight specific messages which can be announcements, updates, instructions, or any other messages deemed important in a channel. This makes it easier for channel members to find and access important information, even in large or active channels where there may be a high volume of incoming messages.

Limitations

Copy link
  • The table below shows the types of channels that support pinned messages. See the channel types section to learn about the differences among various channel types.
Open channelGroup channelSupergroup channel

Pinned messages

Supported, only through the Moderator message feature

Supported, except ephemeral channels

Not supported

  • For open channels: The pinned messages feature is only supported through the Advanced Moderation’s moderator messaging feature. For more information, see the Moderator messaging page.

  • Pinned messages can't be sent as silent messages. The isSilent property should be set to false when pinning or unpinning messages.

  • By default, the maximum number of messages that can be pinned is 10 per channel. To increase this limit, contact our sales team.


Pinning a message on send

Copy link

You can pin a new message that you're sending in a channel by setting the isPinnedMessage property to true. This property belongs to the BaseMessageCreateParams class. The default value for this property is false, meaning that the message being sent is not automatically pinned unless specified.

Pinning an existing message

Copy link

You can pin a message, that is already sent in a channel, using the pinMessage() method of the GroupChannel class. Specify the messageId to pin as shown in the code below.

Note: A group channel has to be created before implementing the code below.

// Send a user message.
let params = UserMessageCreateParams(message: MESSAGE)
channel.sendUserMessage(params: params) { userMessage, error in
    guard let message = userMessage, error == nil else {
        // Handle error.
        return 
    }

    // A text message with detailed configuration is successfully sent to the channel.
    
    // Pin the userMessage.
    channel.pinMessage(messageId: message.messageId) { error in 
        guard error == nil else {
            // Handle error.
            return
        }
        
        // The user message is successfully pinned.
    }
}

The following table shows a list of properties related to the pinned messages feature. The pinnedMessageIds, and lastPinnedMessage properties belong to the GroupChannel class.

List of properties

Copy link
Property nameTypeDescription

pinnedMessageIds

[Int64]?

Specifies an array of message IDs of the pinned messages in a group channel. By default, a maximum of ten messages can be pinned per channel.

lastPinnedMessage

BaseMessage?

Specifies the last message that was pinned in a group channel.

Getting notified when a message is pinned

Copy link

Once a pinned message is sent or an existing message is pinned, the channelDidUpdatePinnedMessages() event delegate is invoked. For further information on GroupChannelDelegate, see the Add or remove a channel delegate page.