Mute and unmute users

更新时间:
复制 MD 格式

The Interactive Message Service provides features for muting and unmuting users, which help administrators manage user communication. Administrators can temporarily prevent certain users from sending messages to maintain a healthy communication environment. They can also remove this restriction when appropriate to restore a user's permissions.

Mute operation APIs

Client APIs

The client-side mute operation API provides the following features:

  • Mute and unmute all members

  • Mute and unmute specific members

Important
  • Only group administrators and the group creator can use this API.

  • Group administrators and the group creator are not affected by mute restrictions.

Server-side APIs

Note

Users who are muted individually must also be unmuted individually. The operations to mute or unmute all members do not affect users who are already muted on an individual basis.

Mute status notifications

  1. When a client successfully joins a group, the callback includes the group's mute status.

    ImJoinGroupReq req = new ImJoinGroupReq();
    req.groupId = groupId;
    groupInterface.joinGroup(req, new ImSdkValueCallback<ImJoinGroupRsp>() {
        @Override
        public void onSuccess(ImJoinGroupRsp data) {
            
        }
    
        @Override
        public void onFailure(Error error) {
    	}
    });
  2. When the mute status of a group changes, such as when specific members are muted or unmuted, the system automatically sends a notification to all clients in that group. To use this feature, you must set a listener callback for group events.

    // Add a listener for the group
    groupManager.addGroupListener(new ImGroupListener() {
        @Override
        public void onMemberChange(String groupId, int memberCount, ArrayList<ImUser> joinUsers, ArrayList<ImUser> leaveUsers) {
            
        }
        @Override
        public void onExit(String groupId, int reason) {
        }
        @Override
        public void onMuteChange(String groupId, ImGroupMuteStatus status) {
        }
        @Override
        public void onInfoChange(String groupId, ImGroupInfoStatus info) {
        }
    });