Quick Reference for AI Agents & Developers
Leave a Group
To stop receiving updates and messages for any particular joined group, you need to leave the group using theleaveGroup() method.
- Java
- Kotlin
| Parameter | Description |
|---|---|
GUID | The GUID of the group you would like to leave |
Real-Time Group Member Left Events
As a member of a group, how do I know if someone has left it when my app is running? If a user leaves a group, the members of the group receive a real-time event in theonGroupMemberLeft() method of the GroupListener class.
- Java
- Kotlin
Missed Group Member Left Events
As a member of a group, how do I know if someone has left it when my app is not running? When you retrieve the list of previous messages, if a member has left any group that the logged-in user is a member of, the list of messages will contain anAction message. An Action message is a sub-class of the BaseMessage class.
For the group member left event, in the Action object received, the following fields can help you get the relevant information:
action-leftactionBy- User object containing the details of the user who left the groupactionFor- Group object containing the details of the group the user has left
Best Practices
Confirm Before Leaving
Confirm Before Leaving
Prompt users to confirm before leaving a group, especially for private groups where rejoining requires an invitation.
Clean Up Local Data
Clean Up Local Data
After leaving a group, consider clearing cached messages and group data from local storage to free up space.
Handle Leave Events in UI
Handle Leave Events in UI
Update your UI immediately when receiving leave events to reflect the current group membership status.
Troubleshooting
Leave Failed - Not a Member
Leave Failed - Not a Member
Symptom:
leaveGroup() fails with “Not a member” error.Cause: User is not currently a member of the group.Solution: Check the hasJoined property of the Group object before attempting to leave.Leave Failed - Last Admin
Leave Failed - Last Admin
Symptom:
leaveGroup() fails when trying to leave as the last admin.Cause: Groups require at least one admin. The last admin cannot leave without transferring ownership or deleting the group.Solution: Either transfer ownership to another member or delete the group if you want to remove it entirely.