Links
Kotlin Chat SDK lets you encode URLs that begin with www
, http
, or https
(plain links) so that they can be rendered as links.
Send message with 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("support").async { result ->
result.onSuccess { channel ->
// join the channel
channel.join().async { joinResult ->
joinResult.onSuccess {
// handle success on joining
// define the text links
val textLinks = listOf(
TextLink(
startIndex = 14,
endIndex = 47,
link = "https://www.linkedin.com/mkelly_vp2"
),
TextLink(
show all 44 linesGet text links
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.
val channel = chat.getChannel("your-channel")
channel.getMessage(16200000000000000).async { result ->
result.onSuccess { message: Message? ->
if (message != null) {
// Access the textLinks property
val textLinks = message.textLinks
if (textLinks != null && textLinks.isNotEmpty()) {
println("The message contains the following text links:")
textLinks.forEach { textLink ->
println("Link: ${textLink.link}, Start Index: ${textLink.startIndex}, End Index: ${textLink.endIndex}")
}
} else {
println("The message does not contain any text links.")
show all 23 lines