On this page

Reference channels

Channel referencing lets users mention channels in messages by typing # followed by at least three letters. Matching channel names appear as suggestions.

Generic referencing

Channel references, user mentions, and links are MessageElement instances with different MentionTarget types.

Suggestions include all channels in the app keyset (up to 100), regardless of user membership. Configure up to 100 channel references per message (default: 10) and display them as links.

Implementation is similar to user mentions and links.

Requires App Context

To reference channels from a keyset, you must enable App Context for your app's keyset in the Admin Portal.

Add channel references

Add channel references with # followed by at least three letters of the channel name (e.g., #Sup).

Method signature

You can add a channel reference by calling the addMention() method with the target of MentionTarget.channel.

Refer to the addMention() method for details.

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.

Create the Hello Alex! I have sent you this link on the #offtopic channel. message where #offtopic is a channel reference.

1

Remove channel references

Remove a channel reference from a draft message with removeMention().

Method signature

You can remove channel references from a draft message by calling the removeMention() method at the exact offset where the channel reference starts.

Refer to the removeMention() method for details.

Offset value

Provide the exact position of the first character; otherwise the element is not removed.

Sample code

Remove the channel reference from the Hello Alex! I have sent you this link on the #offtopic channel. message where #offtopic is a channel reference.

1

Get channel suggestions

The message elements listener returns matching channels from your keyset for the 3-letter string typed after #.

icon

Single listener


Typing #Sup returns channels like Support or Support-Agents. Default: 10 suggestions (max: 100).

Method signature

You must add a message elements listener to receive channel suggestions.

Refer to the addChangeListener() method for details.

Sample code

Create a message draft and add a change listener to listen for channel references.

1

Get referenced channels

Return all channel names referenced in a message with getMessageElements().

Method signature

This method has the following signature:

1message.getMessageElements()

Sample code

Check if the message with the 16200000000000000 timetoken contains any channel references.

1

Get referenced channels (deprecated)

Return all channel names referenced in a message with the referencedChannels getter.

Method signature

This method has the following signature:

1message.referencedChannels

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.

Check if the message with the 16200000000000000 timetoken contains any channel references.

1

Last updated on