Skip to main content

Managing channel tag data

Create and manage channel tag data using the Nexconn SDK. The SDK lets users create Tag objects for organizing channels into groups. Each user can create up to 20 tags. Tag data created on the client syncs with the server.

Tag properties:

ParameterTypeDescription
tagIdStringUnique tag identifier.
tagNameStringTag name (max 15 characters). Duplicate names are allowed.
countintNumber of matching channels.
tip

This page covers tag data management only. For adding tags to channels and retrieving channels by tag, see Tagging Channels.

Create a tag

Use Tag.createTag() with CreateTagParams to create a tag. Each user can create up to 20 tags.

kotlin
val params = CreateTagParams(
tagId = "my_tag_id",
tagName = "Favorites"
)

Tag.createTag(params) { tag, error ->
if (error == null && tag != null) {
// Tag created successfully
} else {
// Failed
}
}

Remove a tag

Use tag.delete() to remove a tag.

kotlin
// Get the tag first, then call delete()
Tag.getTags { tags, error ->
if (error == null && tags != null) {
val tag = tags.find { it.tagId == "my_tag_id" }
tag?.delete { deleteError ->
if (deleteError == null) {
// Tag deleted
}
}
}
}

Update a tag

Use tag.update() to update a tag's name.

kotlin
tag.update("New Name") { error ->
if (error == null) {
// Tag updated
}
}

Get tag list

Use Tag.getTags() to retrieve all tags created by the current user.

kotlin
Tag.getTags { tags, error ->
if (error == null && tags != null) {
tags.forEach { tag ->
println("Tag: ${tag.tagId}, Name: ${tag.tagName}")
}
}
}

Multi-device tag sync

The SDK supports multi-device login for the same user account. Use NCEngine.addTagHandler() to receive notifications when tags are modified on another device. After receiving a notification, call Tag.getTags() to fetch the latest tag data from the server.

tip
  • Modifying tags on the current device does not trigger this callback. The server only notifies the SDK on other devices logged in with the same account.
kotlin
NCEngine.addTagHandler("TAG_SYNC", object : TagHandler {
override fun onTagChanged() {
// Tag definitions changed on another device, refresh
Tag.getTags { tags, error ->
if (error == null && tags != null) {
// Update UI with latest tags
}
}
}

override fun onChannelTagChanged() {
// Channel-tag associations changed on another device, refresh
Tag.getTags { tags, error ->
if (error == null && tags != null) {
// Update UI with latest channel-tag data
}
}
}
})