Groups

Flutter group conversations

A group conversation is one with multiple users that can send and receive messages. Internally a group conversation is called a channel.

Create a group conversation

To create a group conversation, you need to create a groupInfo object and and use it to create a group conversation:

dynamic groupInfo = {
          'groupName': "My group",
          'groupMemberList': ['userId1', 'userId2'],
          'imageUrl': 'https://www.applozic.com/favicon.ico', //for the group icon
          'type': 2, //type for basic groups
          'admin': 'userId1',
          'metadata': { //here we can add any extra data we wish to send
            'plugin': "Flutter",
            'platform': "Android"
          }
        };

  ApplozicFlutter.createGroup(groupInfo)
            .then((groupId) {
              print("Group created sucessfully: " + groupId);
              ApplozicFlutter.launchChatWithGroupId(groupId)
                  .then((value) => print("Launched successfully : " + value))
                  .catchError((error, stack) {
                print("Unable to launch group : " + error.toString());
              });
            })
            .catchError((error, stack) =>
                print("Group created failed : " + error.toString()));

Add member to group

To add a member to a group you need to create a object with the userId of the member to add and the groupId/clientGroupId (either one) of the group.
The clientGroupId provides another way to identify a group.

dynamic detailObject = {
      'userId': "userId", //userId of the user to add
      'groupId': 123456 //groupId of the group to add the user to
    };

Then pass the object to this function:

ApplozicFlutter.addMemberToGroup(detailObject)
        .then((value) => {
              print("Member added successfully."),
              ApplozicFlutter.createToast("Member added successfully.")
            })
        .catchError((e, s) => {
              print("Error adding member."),
              ApplozicFlutter.createToast("Error in adding member.")
            });

Remove member from group

To remove a member from a group you need to great a object with userId of the member to remove and the groupId/clientGroupId (either one) of the group:

dynamic detailObject = {
      'userId': "userId", //userId of the user to remove
      'groupId': 123456 //groupId of the group to remove the user from
    };

Then pass the object to this function:

ApplozicFlutter.removeMemberFromGroup(detailObject)
        .then((value) => {
              print("Member removed successfully."),
              ApplozicFlutter.createToast("Member removed successfully.")
            })
        .catchError((e, s) => {
              print("Error removing member."),
              ApplozicFlutter.createToast("Error in removing member.")
            });

What’s Next

Message API

Did this page help you?