Add Members to Group
You can add members to the group using theaddMembersToGroup() method. This method takes the below parameters:
- GUID- GUID of the group users are to be added to.
- List<GroupMember> members- This is a list of- GroupMemberobjects. In order to add members, you need to create an object of the- GroupMemberclass. The- UIDand the scope of the- GroupMemberare mandatory.
- List<String> bannedMembers- This is the list of- UIDsthat need to be banned from the group. This can be set to- nullif there are no members to be banned.
- Dart
onSuccess() method , you will receive a Map which will contain the UID of the users and the value will either be success or an error message describing why the operation to add the user to the group or ban the user failed.
Real-Time Group Member Added Events
In other words, as a member of a group, how do I know when someone is added to the group when my app is running?When a group member is added by another member, this event is triggered. When a user joins a group on their own, the joined event is triggered.
onMemberAddedToGroup() methods of the GroupListener class.
- onMemberAddedToGroup()- This method is triggered when any user is added to the group so that the logged-in user is informed of the other members added to the group.
- Dart
Member Added to Group event in Message History
In other words, as a member of a group, how do I know when someone is added to the group when my app is not running? When you retrieve the list of previous messages if a member has been added to 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 BaseMessage class.
For the group member added event, in the Action object received, the following fields can help you get the relevant information-
- action-- added
- actionOn- User object containing the details of the user who was added to the group
- actionBy- User object containing the details of the user who added the member to the group
- actionFor- Group object containing the details of the group to which the member was added