Skip to main content

Managing Tag Information Data

tip
  • The IMLib SDK has supported tag creation since version 5.1.1.
  • Starting from version 5.3.0, it is recommended to use interfaces with asynchronous return results, while the original synchronous interfaces are deprecated.

This document describes how to use the interfaces under RCCoreClient to create and manage tag information data. The IMLib SDK allows users to create tag information (RCTagInfo) for marking and grouping conversations. Each user can create up to 20 tags. Tag information data created on the client will be synchronized with the RC server.

The definition of tag information (RCTagInfo) is as follows:

ParameterTypeDescription
tagIdNSStringUnique identifier for the tag, string type, with a maximum length of 10 characters.
tagNameNSStringMaximum length of 15 characters; tag names can be duplicated.
countNSIntegerNumber of conversations under the tag
timestamplong longTimestamp provided by the SDK's internal protocol stack.
tip

This document only describes how to manage tag information data. For information on how to set tags for conversations and how to retrieve conversation data by tag, please refer to Setting and Using Conversation Tags.

Creating Tag Information

Create a tag. Each user can create up to 20 tags.

Sample Code

RCTagInfo *tag = [[RCTagInfo alloc] initWithTagInfo:@"tagId" tagName:@"tagName"];

[[RCCoreClient sharedCoreClient] addTag:tag success:^{

} error:^(RCErrorCode errorCode) {

}];

Removing Tag Information

Remove a tag. Only the tagId from RCTagInfo needs to be provided when removing tag information.

Sample Code

[[RCCoreClient sharedCoreClient] removeTag:@"tagId" success:^{
} error:^(RCErrorCode errorCode) {
}];

Editing Tag Information

Update tag information. Only the tag name (tagName) field in RCTagInfo can be modified. The maximum length is 15 characters, and tag names can be duplicated.

Sample Code

RCTagInfo *tag = [[RCTagInfo alloc] initWithTagInfo:@"tagId" tagName:@"tagName"];

[[RCCoreClient sharedCoreClient] updateTag:tag success:^{

} error:^(RCErrorCode errorCode) {

}];

Retrieving Tag Information List

Retrieve the list of tags created by the current user. The success callback will return a list of RCTagInfo.

Sample Code

[[RCCoreClient sharedCoreClient] getTags:^(NSArray<RCTagInfo *> * _Nonnull tags) {
}];

Multi-Device Synchronization of Tag Information Modifications

Instant Messaging supports multi-device login for the same user account. If your app user modifies tag information on the current device, the SDK will notify the user's other devices. Upon receiving the notification, other devices need to call getTags to retrieve the latest tag information from the RC server.

After setting the delegate, the current device can receive notifications about tag information modifications from other devices.

tip
  • Please call this method after initialization but before connection.
  • Modifying tag information on the current device will not trigger this callback method. The server will only notify the SDK to trigger the callback on other devices logged in with the same user account.

Setting the Delegate

[RCCoreClient sharedCoreClient].tagDelegate = self;

Delegate Method

@protocol RCTagDelegate <NSObject>

/*!
Tag Change

@discussion Adding, deleting, or updating tags on the local device will not trigger this callback method; the result will be directly returned in the block of the relevant method call.
*/
- (void)onTagChanged;

@end

When a user adds, removes, or edits a tag on another device, the SDK will trigger the onTagChanged callback. Upon receiving the notification, call getTags to retrieve the latest tag information from the RC server.