Links

Swift Chat SDK lets you encode URLs that begin with www, http, or https (plain links) so that they can be rendered as links.

You can attach links to the message and publish it using the sendText() method.

Method signature

Head over to the SendText() method for details.

Basic usage

Include these links in a text message: https://www.linkedin.com/mkelly_vp2 and https://admin.pubnub.com/#/login.

chat?.getChannel(channelId: "support") { result in
switch result {
case let .success(channel):
if let channel = channel {
debugPrint("Fetched channel metadata with ID: \(channel.id)")

// Join the channel
channel.join(completion: { joinResult in
switch joinResult {
case .success:
// Handle success on joining
// Define the text links
let textLinks = [
TextLink(startIndex: 14, endIndex: 47, link: "https://www.linkedin.com/mkelly_vp2"),
TextLink(startIndex: 53, endIndex: 84, link: "https://admin.pubnub.com/#/login")
show all 44 lines

You can access the textLinks property of the Message object to return all text links in a given message.

Method signature

This is how you can access the property:

message.textLinks

Basic usage

Get all text links included in the message with the 16200000000000000 timetoken.

// Reference the "your-channel" channel
chat?.getChannel(channelId: "your-channel") { result in
switch result {
case let .success(channel):
if let channel = channel {
debugPrint("Fetched channel metadata with ID: \(channel.id)")
// Fetch the message using the timetoken
channel.getMessage(timetoken: 16200000000000000) { messageResult in
switch messageResult {
case let .success(message):
if let message = message {
// Access the textLinks property
if let textLinks = message.textLinks, !textLinks.isEmpty {
debugPrint("The message contains the following text links:")
for textLink in textLinks {
show all 34 lines
Last updated on