Skip to main content

Managing Tag Information Data

The SDK supports tag creation starting from version 5.1.1.

This document describes how to use interfaces under RongCoreClient to create and manage tag information data. The IMLib SDK allows users to create tag information (TagInfo) 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.

Tag information (TagInfo) parameter description:

ParameterTypeDescription
tagIdStringUnique tag identifier, string type, with a maximum length of 10 characters.
tagNameStringMaximum length of 15 characters. Tag names can be duplicated.
countintNumber of matching conversations.
timestamplongTimestamp provided by the SDK's internal protocol stack.
tip

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

Creating Tag Information

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

Sample Code

RongCoreClient.getInstance().addTag(tagInfo, new IRongCoreCallback.OperationCallback() {

@Override
public void onSuccess() {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});

Removing Tag Information

Remove tags. Only the tagId from the TagInfo needs to be provided when removing tag information.

Sample Code

RongCoreClient.getInstance().removeTag(tagId, new IRongCoreCallback.OperationCallback() {

@Override
public void onSuccess() {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});

Editing Tag Information

You can modify the tag name (tagName) field in TagInfo to update tag information.

Sample Code

RongCoreClient.getInstance().updateTag(tagInfo, new IRongCoreCallback.OperationCallback() {

@Override
public void onSuccess() {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});

Retrieving Tag Information List

Retrieve all tags created by the current user. The success callback returns a list of TagInfo.

Sample Code

RongCoreClient.getInstance().getTags(new IRongCoreCallback.ResultCallback<List<TagInfo>>() {

/**
* Success callback
* @param messages Retrieved message list
*/
@Override
public void onSuccess(List<TagInfo> tagInfos) {

}

@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {

}
});

Multi-Device Synchronization of Tag Information Changes

RC supports multi-device login for the same user account. By setting the tag information change listener IRongCoreListener.TagListener, the current device can receive notifications about tag information modifications made on other devices. Upon receiving a notification, call the getTags method to retrieve the latest tag information from the RC server.

tip
  • Call this method after initialization but before establishing a connection.
  • Modifying tag information on the current device will not trigger this callback method. The server will only notify the SDK to trigger callbacks on other devices logged into the same user account.

When tags are added, removed, or edited on other devices, the onTagChanged callback of TagListener will be triggered. Upon receiving the notification, call getTags to retrieve the latest tag information from the RC server.

RongCoreClient.getInstance().setTagListener(new IRongCoreListener.TagListener{
@Override
public void onTagChanged() {
}
});