When a user leaves a group, members receive a real-time event in onGroupMemberLeft() of the GroupListener class. The callback provides an Action object, the left User, and the Group.
Java
Kotlin
CometChat.addGroupListener(UNIQUE_LISTENER_ID, new CometChat.GroupListener() { @Override public void onGroupMemberLeft(Action action, User leftUser, Group leftGroup) { Log.d(TAG, "User left"); }});
When fetching message history, if a member left a group the logged-in user is part of, the list will contain an Action message with these fields:
action - left
actionBy - User object containing the details of the user who left the group
actionFor - Group object containing the details of the group the user has left
Always remove group listeners when they’re no longer needed (e.g., in onDestroy() or when navigating away). Failing to remove listeners can cause memory leaks and duplicate event handling.