On this page

Links

Encode URLs (www, http, https) as clickable links or create hyperlinks with custom text.

Generic referencing

Channel references, user mentions, and links share the same MessageElement structure with different MentionTarget values.

addMention() adds a link to a draft message.

Method signature

Call addMention() with the target of MentionTarget.url. See addMention() 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 link is a URL.

1

removeMention() removes a link from a draft message.

Method signature

Call removeMention() at the exact offset where the link starts. See removeMention() for details.

Offset value

If you don't provide the position of the first character of the message element to remove, it isn't removed.

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.

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

1

The message elements listener returns link suggestions matching a 3-letter string in the draft message.

icon

Single listener

Method signature

Add a message elements listener to receive link suggestions. See addChangeListener() 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.

1

getMessageElements() returns all text links in a message.

Method signature

This method has the following signature:

1message.getMessageElements()

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 all text links included in the message with the 16200000000000000 timetoken.

1

textLinks returns all text links in a message.

Method signature

This method has the following signature:

1message.textLinks

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 all text links included in the message with the 16200000000000000 timetoken.

1

Last updated on