Group chat modules

Groups is the simplest way to chat with multiple user at any given time.

//For chat logging
LogMessage.enableDebugLogging(BuildConfig.DEBUG)

Create Group#

To create a group call the below method.

Mirrorfly.createGroup(groupName,userJidList,imageFilePath).
then((value) {
//report success
}).catchError((onError) {
//report failed
});
ArgumentTypeDescription
groupNameStringName of the group(cannot be null or empty)
userJidListList<String>List of jids of the member (size cannot be less than 2 excluding group creator)
imageFilePathStringfile path of the image (can be empty)
info

There is an overloading method available for createGroup which accepts image as a File path instead of url id.

caution

If there is no internet or the connection between chat server and the app isn't made create group functionality will be executed and group will be created locally. Until the group is available in server messaging/profile update should be restricted in app side by checking the isGroupInOfflineMode property of RecentChat or ProfileDetails class else an exception will be thrown.

Group profile Update#

Update group name#

User can able to update group name whenever they want by using the below method.

Mirrorfly.updateGroupName (jid,name).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
jidStringjid of the group
nameStringnew name for the group which has to updated

Update group profile image#

User can able to update group profile image whenever they want by using the below method.

To update group profile image as either file or by using uploaded image id:

Mirrorfly.updateGroupProfileImage (jid,imageFilePath).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
jidStringJid of the group
imageFilePathStringFile path of the group profile image

Remove group profile image#

User can able to remove group profile image whenever they want by using the below method.

Mirrorfly.removeGroupProfileImage(jid).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
jidStringJid of the group
caution

If there is no internet or the connection between chat server and the app isn't made group update functionality will be executed locally once the connection is restored it will be updated for other group members and in the server.

Get profile data#

To get the detail of a group call the below method.

Mirrorfly.getProfileDetails(groupJid, fromServer).then((value) {
}).catchError((onError) {
});
ArgumentsTypeDescription
groupJidStringJid of the group
fromServerboolif true fetches data from the server else from local database

Get all Groups#

To fetch all the groups in which you are member of call the below method.

Mirrorfly.getAllGroups(fromServer).then((value) {
var groups = profileFromJson(value);
}).catchError((onError) {
});
caution

Need to call getAllGroups atlas once after user login so that the all the groups info will be fetched and saved in local DB else no group related data will be available.

ArgumentTypeDescription
fromServerboolif true fetches data from the server else fetches data from local database

Get Group Members#

To fetch all the groups members of a group call the below method.

Mirrorfly.getGroupMembersList(groupJid, fromServer).then((value) {
var groupsMembersProfileList = memberFromJson(value);
}).catchError((onError) {
});
caution

Fetching group members from a server will be called internally when required. So , unless it was necessary set false for getServerData.

ArgumentTypeDescription
groupJidStringJid of the group
fromServerboolif true fetches data from the server else fetches data from local database

Check User is a member#

To check whether a user of a given jid is a member of the group

Mirrorfly.isMemberOfGroup(groupJID, userJid).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
groupJIDStringJid of the group
userJidStringJid of the user

Add user to Group#

To add users to a group call the below method.

Mirrorfly.addUsersToGroup(grouJID, userList).then((bool? value) {
});
ArgumentTypeDescription
grouJIDStringJid of the group
userListList<String>Jid list of the new users

Remove a group member#

To remove a user from group call the below method.

Mirrorfly.removeMemberFromGroup(grouJID, userList).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
grouJIDStringJid of the group
userListStringJid of the user who is going to be removed

Make participant as admin#

User can able to make some participant of the group as a admin to the group. The below method can be used to make someone as admin. only admins can perform this action

Mirrorfly.makeAdmin(grouJID, adminJid).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
grouJIDStringjid of the group
adminJidStringjid of the group participant

Check group admin#

User can able to check some participant of the group is a admin or not to the group. The below method can be used to check someone admin or not.The below method will return true if userJid is admin for the provided groupJid.

Mirrorfly.isAdmin(grouJID, userJid).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
grouJIDStringJid of the group
userJidStringJid of the group participant

Group messaging#

Group messaging is very similiar to the single chat messaging. Instead of giving single chat jid , you need to provide group jid. if you don't have group jid, you can prepare that using the above method by giving group id.

Refer this doc for group messaging

Message Delivered list#

To get the list of users to whom a message was successfully delivered call the below method.

Mirrorfly.getGroupMessageDeliveredToList(messageId).then((value) {
}).catchError((onError) {
});

Refer this doc to know more about MessageStatusDetail Class

info

Only messages sent by the current user will have the options to get delivered and read list.

ArgumentTypeDescription
messageIdStringId of a group message

Message Read list#

To get the list of users whom are read/seen the message call the below method.

Mirrorfly.getGroupMessageReadByList(messageId).then((value) {
}).catchError((onError) {
});
info

Only messages sent by the current user will have the options to get delivered and read list.

ArgumentTypeDescription
messageIdStringId of a group message

Leave from a group#

To leave from a group in which you are a member call the below method.

Mirrorfly.leaveFromgroup(grouJID).then((bool? value) {
}).catchError((onError) {
});
ArgumentTypeDescription
grouJIDStringJid of the group

Delete a group#

To delete a group locally call the below method.

Mirrorfly.deleteGroup(grouJID).then((bool? value) {
}).catchError((onError) {
});
warning

Deleting a group only delete the group data locally its doesn't delete the group in the server or to other users.

ArgumentData typeDescription
grouJIDStringJid of the group