Skip to main content

Set chatroom attributes in batches. Updates synchronize automatically to all chatroom members and are returned through the chatroom attribute-change event.

API Definition

/**
* set chatroom attributes
*
* @param chatroomId chatroom ID
* @param attributes Chatroom attributes. Both key and value are strings; up to 100 distinct attributes are supported.
* The client cannot modify a key that was not set by the current user (returns JErrorCode.CHATROOM_KEY_UNAUTHORIZED).
* @param callback completion callback
* JErrorCode.NONE indicates that all attributes were set successfully.
* Other codes indicate that one or more keys failed. Every failed key is returned with its error code; see JErrorCode for the corresponding definition.
*/
void setAttributes(String chatroomId, Map<String, String> attributes, IChatroomAttributesUpdateCallback callback);

Example

Map<String, String> attributes = new HashMap<>();
attributes.put("key1", "value1");
attributes.put("key2", "value2");
JIM.getInstance().getChatroomManager().setAttributes("chatroomId1", attributes, new IChatroomManager.IChatroomAttributesUpdateCallback() {
@Override
public void onComplete(int errorCode, Map<String, Integer> failedKeys) {

}
});