Pinned messages
Pin messages to channels for easy access. Only one message can be pinned per channel at a time.
Use cases:
- Essential announcements and updates
- Action items and reminders
- Polls and persistent questions
Requires App Context and Message Persistence
Enable App Context and Message Persistence in the Admin Portal.
Pin
pin() and pinMessage() attach a message to a channel. Call pin() on a message object or pinMessage() on a channel object.
Alternatively, you can also use other Chat SDK methods to pin a message in a thread (thread message) to the thread channel or the parent channel.
Method signature
These methods take the following parameters:
-
pin()(on theMessageobject)1message.pin() async throws -> ChannelImpl -
pinMessage()(on theChannelobject)1channel.pinMessage(
2 message: MessageImpl
3) async throws -> ChannelImpl
Input
| Parameter | Required in pin() | Required in pinMessage() | Description |
|---|---|---|---|
messageType: MessageImplDefault: n/a | No | Yes | MessageImpl object that you want to pin to the selected channel. |
Output
| Parameter | Description |
|---|---|
ChannelImpl | The updated channel metadata. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Pin the last message on the incident-management channel.
-
pin()1 -
pinMessage()1
Get
getPinnedMessage() retrieves the currently pinned message.
Method signature
This method has the following signature:
1channel.getPinnedMessage() async throws -> MessageImpl?
Input
This method doesn't take any parameters.
Output
| Parameter | Description |
|---|---|
MessageImpl | Returned MessageImpl object. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Get the message pinned to the incident-management channel.
1
Unpin
unpinMessage() unpins a message from the channel.
Alternatively, you can also use other Chat SDK methods to unpin a message in a thread (thread message) from the thread channel or the parent channel.
Method signature
This method has the following signature:
1channel.unpinMessage() async throws -> ChannelImpl
Input
This method doesn't take any parameters.
Output
| Parameter | Description |
|---|---|
ChannelImpl | The updated channel metadata. |
Sample code
Sample code
The code samples in Swift Chat SDK focus on asynchronous code execution.
You can also write synchronous code as the parameters are shared between the async and sync methods but we don't provide usage examples of such.
Unpin the message from the incident-management channel.
1