Group chat modules
Groups is the simplest way to chat with multiple user at any given time.
#
Group ConfigurationsWe need to do some additional configurations for Group Chats in your project Application
class inside the onCreate() method build the ChatSDK Builder and provide the necessary data. An example can be found below.
- Java
- Kotlin
#
Preparing group chat jidAlmost of the sdk methods expect jid as a input parameter, so sdk provides below utility method to prepare the group jid from the group id. The method prepares the group chat jid from the given string by using chat config provided via [com.contusflysdk.api.ChatConnectionManager.initialize] method.
Note: The below characters is not allowed in groupId: U+0022 (") U+0026 (&) U+0027 (') U+002F (/) U+003A (:) U+003C (<) U+003E (>) U+0040 (@).
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_ID | String | Id of the group |
caution
If group chat feature unavailable for your plan then below methods will throw 403 exception.
#
Create GroupTo create a group call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_NAME | String | Name of the group(cannot be null or empty) |
MEMBERS_JID_LIST | List<String> | List of jids of the member (size cannot be less than 2 |
excluding group creator) | ||
GROUP_IMAGE_ID | String | url id of the uploaded image (can be empty) |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
info
There is an overloading method available for createGroup which accepts image as a File
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.
#
Move offline group to onlineTo move the group which is created locally to online(create in server) call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the offline group |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Group profile Update#
Update group nameUser can able to update group name whenever they want by using the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | jid of the group |
GROUP_NAME | String | new name for the group which has to updated |
LISTENER | ChatActionListener | listener callback to observe the action status |
#
Update group profile imageUser 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:
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
IMAGE_FILE | File | File object of the group profile image |
IMAGE_ID | String | new profile image as a url which has to updated for the group |
LISTENER | ChatActionListener | callback to observe the action status |
#
Remove group profile imageUser can able to remove group profile image whenever they want by using the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
LISTENER | ChatActionListener | callback to observe the action status |
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 dataTo get the detail of a group call the below method.
- Java
- Kotlin
Arguments | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
FETCH_FROM_SERVER | boolean | if true fetches data from the server else from local database |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Get all GroupsTo fetch all the groups in which you are member of call the below method.
- Java
- Kotlin
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.
Argument | Type | Description |
---|---|---|
GET_SERVER_DATA | boolean | if true fetches data from the server else fetches data from local database |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Get Group MembersTo fetch all the groups members of a group call the below method.
- Java
- Kotlin
caution
Fetching group members from a server will be called internally when required. So , unless it was necessary set false
for getServerData.
Argument | Type | Description |
---|---|---|
GET_SERVER_DATA | boolean | if true fetches data from the server else fetches data from local database |
GROUP_JID | String | Jid of the group |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Check User is a memberTo check whether a user of a given jid is a member of the group
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_ID | String | Jid of the group |
USER_JID | String | Jid of the user |
#
Validate Members list server callTo check whether a server call to get the members list for a group is required or not call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
#
Group members countTo get count of members in a group call the below method.
- Java
- Kotlin
Arguments | Data type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
#
Get user list to add to a groupTo get the list of users who are eligible to add to a group while creating or to a old group call one of the the below method.
- Java
- Kotlin
warning
Those two methods above are available only if contact sync is enabled.
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
#
Add user to GroupTo add users to a group call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
NEW_USERS_JID_LIST | List<String> | Jid list of the new users |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Remove a group memberTo remove a user from group call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
REMOVING_MEMBER_JID | String | Jid of the user who is going to be removed |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Make participant as adminUser 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
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | jid of the group |
NEW_ADMIN_JID | String | jid of the group participant |
LISTENER | ChatActionListener | callback to observe the action status |
#
Check group adminUser 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
.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
USER_JID | String | Jid of the group participant |
#
Group messagingGroup 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 listTo get the list of users to whom a message was successfully delivered call the below method.
- Java
- Kotlin
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.
Argument | Type | Description |
---|---|---|
MESSAGE_ID | String | Id of a group message |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Message Read listTo get the list of users whom are read/seen the message call the below method.
- Java
- Kotlin
info
Only messages sent by the current user will have the options to get delivered and read list.
Argument | Type | Description |
---|---|---|
MESSAGE_ID | String | Id of a group message |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Get message status countTo get the count of statuses for a given message id call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
MESSAGE_ID | String | Id of the message |
#
Leave from a groupTo leave from a group in which you are a member call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Delete a groupTo delete a group locally call the below method.
- Java
- Kotlin
warning
Deleting a group only delete the group data locally its doesn't delete the group in the server or to other users.
Argument | Data type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |
CALLBACK | FlyCallback | FlyCallback implemented as lambda expression |
#
Delete offline groupTo delete a offline group which is not yet available online(created in server) call the below method.
- Java
- Kotlin
Argument | Type | Description |
---|---|---|
GROUP_JID | String | Jid of the group |