Skip to main content

Manage Tag Information Data

SDK supports tag creation starting from version 5.1.1.

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

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

ParameterTypeDescription
tagIdNSStringThe unique identifier of the tag, string type, with a maximum length of 10 characters.
tagNameNSStringThe name of the tag, with a maximum length of 15 characters. Tag names can be duplicated.
countNSIntegerThe number of conversations under the tag.
timestamplong longThe timestamp is provided by the SDK's internal protocol stack.
tip

This article 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 Set and Use Conversation Tags.

Create Tag Information

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

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

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

} error:^(RCErrorCode errorCode) {

}];

Remove Tag Information

Remove a tag. Only the tagId from RCTagInfo is required to remove tag information.

[[RCCoreClient sharedCoreClient] removeTag:@"tagId" success:^{

} error:^(RCErrorCode errorCode) {

}];

Edit 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.

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

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

} error:^(RCErrorCode errorCode) {

}];

Get Tag Information List

tip

Starting from version 5.3.0 of RCCoreClient, it is recommended to use the asynchronous result-returning interface below, while the original synchronous interface is deprecated.

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

[[RCCoreClient sharedCoreClient] getTags:^(NSArray<RCTagInfo *> * _Nonnull tags) {
NSArray *array = tags;
}];
ParameterTypeDescription
completionBlockAsynchronous callback, returning a list of tag information (RCTagInfo).

Multi-Device Synchronization of Tag Information Changes

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 of tag information changes 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.

Set Delegate

[RCCoreClient sharedCoreClient].tagDelegate = self;

Delegate Method

@protocol RCTagDelegate <NSObject>

/*!
Tag change

@discussion Adding, deleting, or updating tags on this end will not trigger this callback method. The callback will be directly returned in the block of the related method.
*/
- (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.