Manage Tag Information Data
SDK supports tag creation starting from version 5.1.1.
This document describes how an App can use the interfaces under RongCoreClient to create and manage tag information data. The client SDK allows users to create tag information (TagInfo) 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 (TagInfo) is as follows:
Parameter | Type | Description |
---|---|---|
tagId | String | Unique identifier for the tag, string type, with a maximum length of 10 characters. |
tagName | String | Maximum length of 15 characters, tag names can be duplicated. |
count | int | Number of matching conversations. |
timestamp | long | Timestamp provided by the SDK's internal protocol stack. |
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 tags, please refer to Set and Use Conversation Tags.
Create Tag Information
Create a tag. Each user can create up to 20 tags.
RongCoreClient.getInstance().addTag(tagInfo, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
});
Remove Tag Information
Remove a tag. Only the tagId
from the TagInfo needs to be passed when removing tag information.
RongCoreClient.getInstance().removeTag(tagId, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
});
Edit Tag Information
Update tag information. You can modify the tagName
field in the TagInfo.
RongCoreClient.getInstance().updateTag(tagInfo, new IRongCoreCallback.OperationCallback() {
@Override
public void onSuccess() {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
});
Retrieve Tag Information List
Retrieve the list of tag information created by the current user. The success callback will return a list of TagInfo.
RongCoreClient.getInstance().getTags(new IRongCoreCallback.ResultCallback<List<TagInfo>>() {
/**
* Callback on success
* @param messages List of retrieved messages
*/
@Override
public void onSuccess(List<TagInfo> tagInfos) {
}
@Override
public void onError(IRongCoreEnum.CoreErrorCode coreErrorCode) {
}
});
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 tag information change listener IRongCoreListener.TagListener, the current device can receive notifications of tag information changes from other devices.
- 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.
RongCoreClient.getInstance().setTagListener(new IRongCoreListener.TagListener{
@Override
public void onTagChanged() {
}
});
When a user adds, removes, or edits a tag on another device, the TagListener
will trigger the onTagChanged
callback. Upon receiving the notification, call getTags
to retrieve the latest tag information from the RC server.