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 types.
Add links
AddMention() adds a link to a draft message. Use CreateUrlMentionTarget() to create a mention target linking to a specified URL.
Method signature
Call AddMention() with MentionTarget of type Url. See AddMention() for details.
Refer to the AddMention() method for details.
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Create the Hello Alex! I have sent you this link on the #offtopic channel. message where link is a URL.
Actor.h
1
Actor.cpp
1
Remove links
RemoveMention() removes a link from a draft message.
Method signature
Call RemoveMention() at the exact offset where the link starts. See RemoveMention() for details.
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
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Remove the link from the Hello Alex! I have sent you this link on the #offtopic channel. message where link is a URL.
Actor.h
1
Actor.cpp
1
Get link suggestions
The message elements listener returns link suggestions along with user mentions and channel references.
Method signature
Refer to the Listen for message draft changes (with suggestions) section for details.
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Insert the first suggested link whenever the draft is updated and links are detected.
Actor.h
1
Actor.cpp
1
Get text links
Removed method
TextLinks() and GetTextLinks() have been removed from the Message object in the latest version of the Unreal Chat SDK. Links are now managed through MessageDraft and message elements.