Manage channel tag data
Create and manage tags to organize channels. Each user can create up to 20 tags. Tag data is synced to the Nexconn server.
NCTag properties
| Property | Type | Description |
|---|---|---|
tagId | NSString | Unique tag identifier (max 10 chars) |
tagName | NSString | Tag name (max 15 chars) |
count | NSInteger | Number of channels in this tag |
timestamp | int64 | Tag creation timestamp (milliseconds) |
tip
This guide covers tag data only. For assigning tags to channels and querying channels by tag, see Set and Use Channel Tags.
Create a tag
Call NCTag.createTag(_:completion:):
- Swift
- Objective-C
swift
import NexconnChatSDK
let params = CreateTagParams(tagId: "tag001", tagName: "Work")
Tag.createTag(params: params) { tag, error in
if let tag {
print("Tag created: \(tag.tagId) (\(tag.tagName))")
} else {
print("Failed: \(error?.localizedDescription ?? "unknown error")")
}
}
Objective C
NCCreateTagParams *params = [[NCCreateTagParams alloc] initWithTagId:@"tag001" tagName:@"Work"];
[NCTag createTagWithParams:params completion:^(NCTag *tag, NCError *error) {
if (tag) {
NSLog(@"Tag created: %@ (%@)", tag.tagId, tag.tagName);
} else {
NSLog(@"Failed: %@", error);
}
}];
Get all tags
- Swift
- Objective-C
swift
import NexconnChatSDK
Tag.getTags { tags, error in
for tag in tags ?? [] {
print("Tag: \(tag.tagId) — \(tag.tagName)")
}
}
Objective C
[NCTag getTagsWithCompletion:^(NSArray<NCTag *> *tags, NCError *error) {
for (NCTag *tag in tags) {
NSLog(@"Tag: %@ — %@", tag.tagId, tag.tagName);
}
}];
Remove a tag
- Swift
- Objective-C
swift
import NexconnChatSDK
let tag: Tag? = nil // Replace with a Tag instance from Tag.getTag/getTags
guard let tag else { return }
tag.delete { error in
if error == nil {
print("Tag removed.")
}
}
Objective C
NCTag *tag; // Obtained from NCTag.getTags
[tag deleteWithCompletion:^(NCError *error) {
if (error == nil) {
NSLog(@"Tag removed.");
}
}];
Update a tag name
- Swift
- Objective-C
swift
import NexconnChatSDK
let tag: Tag? = nil // Replace with a Tag instance from Tag.getTag/getTags
guard let tag else { return }
tag.update(tagName: "Updated Name") { error in
if error == nil {
print("Tag updated.")
}
}
Objective C
[tag updateTagName:@"Updated Name" completion:^(NCError *error) {
if (error == nil) {
NSLog(@"Tag updated.");
}
}];