Chat APIs and In-app Messaging SDKs for Developers, by Developers

Applozic powers multi-platform Chat APIs and in-app Messaging SDKs for Android, iOS and the Web that will enable you to build advanced in-app chat solutions your users will love.

Integrate chat in your application with completely customizable UI kits, powerful messaging APIs and SDKs, developed with exceptional security measures in mind.

Documentation    API Explorer

Deafult group type

If you are using our default UI for creating a group, you can set the default group type in applozic-settings.json file under the property "defaultGroupType".

Default is Public group (2). Learn more about different group types here. Following is the list of available group types:
PRIVATE(1),
PUBLIC(2),
BROADCAST(5),
OPEN(6),
GROUPOFTWO(7),
CONTACT_GROUP(9),
SUPPORT_GROUP(10)

Create a Group

You can create a group with a specific group type as below:
Private group with type : Channel.GroupType.PRIVATE.getValue().intValue()
Public group with type : Channel.GroupType.PUBLIC.getValue().intValue()
Open group with type : Channel.GroupType.OPEN.getValue().intValue()

📘

Group/channel metadata is optional.

Update Group Action Messages

There are 3 ways to change action messages in Group/Channel :

  1. You can change the action message text as your custom message, You can set group metadata for messages like the created group, left the group, removed from the group, group deleted, group icon changed and group name changed as below :
ChannelMetadata channelMetadata = new ChannelMetadata();
 channelMetadata.setCreateGroupMessage(ChannelMetadata.ADMIN_NAME + " created " + ChannelMetadata.GROUP_NAME);
 channelMetadata.setAddMemberMessage(ChannelMetadata.ADMIN_NAME + " added " + ChannelMetadata.USER_NAME);
 channelMetadata.setRemoveMemberMessage(ChannelMetadata.ADMIN_NAME + " removed " + ChannelMetadata.USER_NAME);
 channelMetadata.setGroupNameChangeMessage(ChannelMetadata.USER_NAME + " changed group name " + ChannelMetadata.GROUP_NAME);
 channelMetadata.setJoinMemberMessage(ChannelMetadata.USER_NAME + " joined");
 channelMetadata.setGroupLeftMessage(ChannelMetadata.USER_NAME + " left group " + ChannelMetadata.GROUP_NAME);
 channelMetadata.setGroupIconChangeMessage(ChannelMetadata.USER_NAME + " changed icon");
 channelMetadata.setDeletedGroupMessage(ChannelMetadata.ADMIN_NAME + " deleted group " + ChannelMetadata.GROUP_NAME);
val channelMetadata = ChannelMetadata()
  channelMetadata.createGroupMessage = ChannelMetadata.ADMIN_NAME + " created " + ChannelMetadata.GROUP_NAME
  channelMetadata.addMemberMessage = ChannelMetadata.ADMIN_NAME + " added " + ChannelMetadata.USER_NAME
   channelMetadata.removeMemberMessage = ChannelMetadata.ADMIN_NAME + " removed " + ChannelMetadata.USER_NAME
  channelMetadata.groupNameChangeMessage = ChannelMetadata.USER_NAME + " changed group name " + ChannelMetadata.GROUP_NAME
  channelMetadata.joinMemberMessage = ChannelMetadata.USER_NAME + " joined"
  channelMetadata.groupLeftMessage = ChannelMetadata.USER_NAME + " left group " + ChannelMetadata.GROUP_NAME
  channelMetadata.groupIconChangeMessage = ChannelMetadata.USER_NAME + " changed icon"
 channelMetadata.deletedGroupMessage = ChannelMetadata.ADMIN_NAME + " deleted group " + ChannelMetadata.GROUP_NAME

Following place holders will be replaced:
ChannelMetadata.ADMIN_NAME : admin name of the group
ChannelMetadata.USER_NAME : user name of the user
ChannelMetadata.GROUP_NAME : group name

  1. To hide the group action messages from the chat screen and turn off their notifications, set the channel metadata as shown below and pass this while creating a group or in group update
ChannelMetadata channelMetadata = new ChannelMetadata();
channelMetadata.hideAllMetadataMessages();//to hide all metadata messages.
val channelMetadata = ChannelMetadata()
channelMetadata.hideAllMetadataMessages() //to hide all metadata messages.
  1. To disable the particular group action message you need to pass the empty string as given in the following example.

Example: Disabling group member remove message

To disable the message you need to pass the empty string as shown below:

channelMetadata.setRemoveMemberMessage("");
channelMetadata.removeMemberMessage = "";
  1. To turn off the notification for group action messages set the channel metadata as shown below and pass this while creating a group or in group update.
ChannelMetadata channelMetadata = new ChannelMetadata();
channelMetadata.setAlertMetadataNotification(false);//disable notification
val channelMetadata = ChannelMetadata()
channelMetadata.isAlertMetaDataNotfication = false

Make the following imports:

import com.applozic.mobicomkit.api.people.ChannelInfo;
import com.applozic.mobicomkit.channel.service.ChannelService;

Create the Group as below:

AlChannelCreateAsyncTask.TaskListenerInterface channelCreateTaskListener = new AlChannelCreateAsyncTask.TaskListenerInterface() {
            @Override
            public void onSuccess(Channel channel, Context context) {
                Log.i("Group","Group response :"+channel);

            }

            @Override
            public void onFailure(ChannelFeedApiResponse channelFeedApiResponse, Context context) {

            }

        };

        List<String> groupMembersUserIdList = new ArrayList<>();
        groupMembersUserIdList.add("user1");
        groupMembersUserIdList.add("user2");
        groupMembersUserIdList.add("user3");//Note:while creating group exclude logged in userId from list
        ChannelInfo channelInfo = new ChannelInfo("Group name",groupMembersUserIdList);
        channelInfo.setType(Channel.GroupType.PUBLIC.getValue().intValue()); //group type
        channelInfo.setImageUrl(""); //pass group image link URL
        //channelInfo.setChannelMetadata(channelMetadata); //Optional option for setting group meta data
        //channelInfo.setClientGroupId(clientGroupId); //Optional if you have your own groupId then you can pass here

AlChannelCreateAsyncTask channelCreateAsyncTask = new AlChannelCreateAsyncTask(context,channelInfo,channelCreateTaskListener);
val channelCreateTaskListener: AlChannelCreateAsyncTask.TaskListenerInterface = object : AlChannelCreateAsyncTask.TaskListenerInterface {
            override fun onSuccess(channel: Channel?, context: Context?) {
                if (channel != null) {
                    Log.i("Group", "Group response :$channel")
                }
            }

            override fun onFailure(channelFeedApiResponse: ChannelFeedApiResponse?, context: Context?) {
                if (channelFeedApiResponse != null) {
                    
                }
            }
        }

        val groupMembersUserIdList: MutableList<String> = ArrayList()
        groupMembersUserIdList.add("user1")
        groupMembersUserIdList.add("user2")
        groupMembersUserIdList.add("user3") //Note:while creating group exclude logged in userId from list

        val channelInfo = ChannelInfo("Group name", groupMembersUserIdList)
        channelInfo.type = Channel.GroupType.PUBLIC.getValue().intValue() //group type

        channelInfo.imageUrl = "" //pass group image link URL
        
        //channelInfo.setChannelMetadata(channelMetadata); //Optional option for setting group meta data
        //channelInfo.setClientGroupId(clientGroupId); //Optional if you have your own groupId then you can pass here
val channelCreateAsyncTask = AlChannelCreateAsyncTask(context, channelInfo, channelCreateTaskListener)

Then execute the task using:

AlTask.execute(channelCreateAsyncTask);
AlTask.execute(channelCreateAsyncTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use channelCreateAsyncTask.execute(); instead.

📘

Currently, 100 users can be added to a Public and Private group. This number can be increased on request.

User role specific to a group

While adding the users to a group you can specify the roles for them. Group roles are basically of 3 types:

  1. ADMIN (1) - Full Access to group.
  2. MODERATOR(2) - Can add/remove users , update group info.
  3. NORMAL USER(3) - Can update group Info.

To add members to the group while specifying their role first create the following task:

AlChannelCreateAsyncTask.TaskListenerInterface channelCreateTaskListener = new AlChannelCreateAsyncTask.TaskListenerInterface() {
            @Override
            public void onSuccess(Channel channel, Context context) {
                Log.i("Group","Group response :"+channel);

            }

            @Override
            public void onFailure(ChannelFeedApiResponse channelFeedApiResponse, Context context) {

            }
        };

ChannelInfo channelInfo = new ChannelInfo("Group name",groupMembersUserIdList);
channelInfo.setType(Channel.GroupType.PUBLIC.getValue().intValue()); //group type
channelInfo.setImageUrl(""); //pass group image link URL

List<ChannelInfo.GroupUser> users = new ArrayList<>();
//SETTING ROLE AS 1 FOR ADMIN
users.add(channelInfo.new GroupUser().setUserId(<userId>).setGroupRole(1));
//SETTING ROLE AS 2 FOR MODERATOR
users.add(channelInfo.new GroupUser().setUserId(<userId>).setGroupRole(2));
//SETTING ROLE AS 3 FOR USER
users.add(channelInfo.new GroupUser().setUserId(<userId>).setGroupRole(3));

channelInfo.setUsers(users);

AlChannelCreateAsyncTask channelCreateAsyncTask = new AlChannelCreateAsyncTask(context,channelInfo,channelCreateTaskListener);
val channelInfo = ChannelInfo("groupName", ArrayList())
val users: MutableList<ChannelInfo.GroupUser> = ArrayList()

//SETTING ROLE AS 1 FOR ADMIN
 users.add(channelInfo.GroupUser().setUserId(< adminUserId >).setGroupRole(1))

//SETTING ROLE AS 2 FOR MODERATOR
users.add(channelInfo.GroupUser().setUserId(< userId >).setGroupRole(2))

//SETTING ROLE AS 3 FOR USER
users.add(channelInfo.GroupUser().setUserId(< userId >).setGroupRole(3))

channelInfo.users = users

val channelCreateTaskListener: AlChannelCreateAsyncTask.TaskListenerInterface = object : AlChannelCreateAsyncTask.TaskListenerInterface {
            override fun onSuccess(channel: Channel?, context: Context?) {
                if (channel != null) {
                    Log.i("Group", "Group response :$channel")
                }
            }

            override fun onFailure(channelFeedApiResponse: ChannelFeedApiResponse?, context: Context?) {}
        }

val channelCreateAsyncTask = AlChannelCreateAsyncTask(context, channelInfo, channelCreateTaskListener)

Then execute the task using:

AlTask.execute(channelCreateAsyncTask);
AlTask.execute(channelCreateAsyncTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use channelCreateAsyncTask.execute(); instead.

Creating a Support group

You can create a support group by setting the group type as 10 and setting the group admin messages as empty. Use the below code to create a support group:

ChannelInfo channelInfo = new ChannelInfo("groupName",new ArrayList());
List<ChannelInfo.GroupUser> users = new ArrayList<>();

//SETTING ROLE AS 1 FOR AGENT
users.add(channelInfo.new GroupUser().setUserId(<agentId>).setGroupRole(1));

//SETTING ROLE AS 2 FOR BOT
users.add(channelInfo.new GroupUser().setUserId(<botId>).setGroupRole(2));

//SETTING ROLE AS 3 FOR USER
users.add(channelInfo.new GroupUser().setUserId(<loggedInUserId>).setGroupRole(3));

 channelInfo.setType(10);
 channelInfo.setUsers(users);
 channelInfo.setAdmin(<agentId>);//you can set admin as one of your agents you are adding in the group
 
 Map<String, String> metadata = new HashMap<>();
        metadata.put("CREATE_GROUP_MESSAGE", "");
        metadata.put("REMOVE_MEMBER_MESSAGE", "");
        metadata.put("ADD_MEMBER_MESSAGE", "");
        metadata.put("JOIN_MEMBER_MESSAGE", "");
        metadata.put("GROUP_NAME_CHANGE_MESSAGE", "");
        metadata.put("GROUP_ICON_CHANGE_MESSAGE", "");
        metadata.put("GROUP_LEFT_MESSAGE", "");
        metadata.put("DELETED_GROUP_MESSAGE", "");
        metadata.put("GROUP_USER_ROLE_UPDATED_MESSAGE", "");
        metadata.put("GROUP_META_DATA_UPDATED_MESSAGE", "");
        metadata.put("HIDE", "true");

channelInfo.setMetadata(metadata);
        
AlChannelCreateAsyncTask.TaskListenerInterface listener = new AlChannelCreateAsyncTask.TaskListenerInterface(){
                @Override
                public void onSuccess(Channel channel, Context context) {
                   //group Created
                }

                @Override
                public void onFailure(ChannelFeedApiResponse channelFeedApiResponse, Context context) {
                   //Some error has occured
                }
            };
            
AlChannelCreateAsyncTask alChannelCreateAsyncTask = new AlChannelCreateAsyncTask(context, channelInfo, listener);
val channelInfo = ChannelInfo("groupName", ArrayList())
val users: MutableList<ChannelInfo.GroupUser> = ArrayList()

//SETTING ROLE AS 1 FOR AGENT
users.add(channelInfo.GroupUser().setUserId(< agentId >).setGroupRole(1))

//SETTING ROLE AS 2 FOR BOT
users.add(channelInfo.GroupUser().setUserId(< botId >).setGroupRole(2))

//SETTING ROLE AS 3 FOR USER
 users.add(channelInfo.GroupUser().setUserId(< loggedInUserId >).setGroupRole(3))

channelInfo.type = 10
channelInfo.users = users
channelInfo.admin = < agentId >

val metadata: MutableMap<String, String> = HashMap()
        metadata["CREATE_GROUP_MESSAGE"] = ""
        metadata["REMOVE_MEMBER_MESSAGE"] = ""
        metadata["ADD_MEMBER_MESSAGE"] = ""
        metadata["JOIN_MEMBER_MESSAGE"] = ""
        metadata["GROUP_NAME_CHANGE_MESSAGE"] = ""
        metadata["GROUP_ICON_CHANGE_MESSAGE"] = ""
        metadata["GROUP_LEFT_MESSAGE"] = ""
        metadata["DELETED_GROUP_MESSAGE"] = ""
        metadata["GROUP_USER_ROLE_UPDATED_MESSAGE"] = ""
        metadata["GROUP_META_DATA_UPDATED_MESSAGE"] = ""
        metadata["HIDE"] = "true"

channelInfo.setMetadata(metadata)

val listener: AlChannelCreateAsyncTask.TaskListenerInterface = object : AlChannelCreateAsyncTask.TaskListenerInterface {
            override fun onSuccess(channel: Channel?, context: Context?) {
                //group Created
            }

            override fun onFailure(channelFeedApiResponse: ChannelFeedApiResponse?, context: Context?) {
                //Some error has occurred
            }
        }
val alChannelCreateAsyncTask = AlChannelCreateAsyncTask(context, channelInfo, listener)

Execute the task:

AlTask.execute(alChannelCreateAsyncTask);
AlTask.execute(alChannelCreateAsyncTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use alChannelCreateAsyncTask.execute(); instead.

Add Member to Group

Make the following import:

import com.applozic.mobicomkit.uiwidgets.async.ApplozicChannelAddMemberTask;

You can add memeber to a group by creating a ApplozicChannelAddMemberTask as shown below:

ApplozicChannelAddMemberTask.ChannelAddMemberListener channelAddMemberListener =  new ApplozicChannelAddMemberTask.ChannelAddMemberListener() {
            @Override
            public void onSuccess(String response, Context context) {
                //Response will be "success" if user is added successfully
                Log.i("ApplozicChannelMember","Add Response:" + response);
            }

            @Override
            public void onFailure(String response, Exception e, Context context) {

            }
        };

        ApplozicChannelAddMemberTask applozicChannelAddMemberTask =  new ApplozicChannelAddMemberTask(context,channelKey,userId,channelAddMemberListener);//pass channel key and userId whom you want to add to channel
val channelAddMemberListener: ApplozicChannelAddMemberTask.ChannelAddMemberListener = object : ApplozicChannelAddMemberTask.ChannelAddMemberListener {
            override fun onSuccess(response: String?, context: Context?) {
                if (!TextUtils.isEmpty(response)) {
                    //Response will be "success" if user is added successfully
                    Log.i("ApplozicChannelMember", "Add Response:$response")
                }
            }

            override fun onFailure(response: String?, e: java.lang.Exception?, context: Context?) {}
        }
val applozicChannelAddMemberTask = ApplozicChannelAddMemberTask(context, channelKey, userId, channelAddMemberListener) //pass channel key and userId whom you want to add to channel

Parameter

Description

channelKey

Unique identifier of the group/channel

userId

Unique identifier of the user

Then execute the task:

AlTask.execute(applozicChannelAddMemberTask);
AlTask.execute(applozicChannelAddMemberTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use applozicChannelAddMemberTask.execute((Void)null); instead.

Remove Member from Group

Make the following import:

import com.applozic.mobicomkit.uiwidgets.async.ApplozicChannelRemoveMemberTask;

You can remove the memeber from a group as below:
First create a task:

ApplozicChannelRemoveMemberTask.ChannelRemoveMemberListener channelRemoveMemberListener = new ApplozicChannelRemoveMemberTask.ChannelRemoveMemberListener() {
            @Override
            public void onSuccess(String response, Context context) {
                //Response will be "success" if user is removed successfully
                Log.i("ApplozicChannel","remove member response:"+response);
            }

            @Override
            public void onFailure(String response, Exception e, Context context) {

            }
        };

  ApplozicChannelRemoveMemberTask applozicChannelRemoveMemberTask =  new ApplozicChannelRemoveMemberTask(context,channelKey,userId,channelRemoveMemberListener);//pass channelKey and userId whom you want to remove from channel
val channelRemoveMemberListener: ChannelRemoveMemberListener = object : ChannelRemoveMemberListener {
            override fun onSuccess(response: String?, context: Context?) {
                //Response will be "success" if user is removed successfully
                if (response != null) {
                    Log.i("ApplozicChannel", "remove member response:$response")

                }
            }

            override fun onFailure(response: String?, e: java.lang.Exception?, context: Context?) {}
        }
val applozicChannelRemoveMemberTask = ApplozicChannelRemoveMemberTask(context, channelKey, userId, channelRemoveMemberListener) //pass channelKey and userId whom you want to remove from channel

Parameter

Description

channelKey

Unique identifier of the group/channel

userId

Unique identifier of the user

Then execute the task:

AlTask.execute(applozicChannelRemoveMemberTask);
AlTask.execute(applozicChannelRemoveMemberTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use applozicChannelRemoveMemberTask.execute((Void)null); instead.

📘

Only admin can remove member from the group/channel.

Leave Group

Make the following import:

import com.applozic.mobicomkit.uiwidgets.async.ApplozicChannelLeaveMember;

To leave a group create a task as shown below:

ApplozicChannelLeaveMember.ChannelLeaveMemberListener  channelLeaveMemberListener  = new ApplozicChannelLeaveMember.ChannelLeaveMemberListener() {
            @Override
            public void onSuccess(String response, Context context) {
               //Response will be "success" if user is left successfully
                Log.i("ApplozicChannel","Leave member respone:"+response);
            }

            @Override
            public void onFailure(String response, Exception e, Context context) {

            }
        };

  ApplozicChannelLeaveMember applozicChannelLeaveMember = new ApplozicChannelLeaveMember(context,channelKey,userId,channelLeaveMemberListener);//pass channelKey and userId
val channelLeaveMemberListener: ChannelLeaveMemberListener = object : ChannelLeaveMemberListener {
            override fun onSuccess(response: String?, context: Context?) {
                //Response will be "success" if user is left successfully
                if (!TextUtils.isEmpty(response)) {
                    Log.i("ApplozicChannel", "Leave member respone:$response")
                }
            }

            override fun onFailure(response: String?, e: java.lang.Exception?, context: Context?) {}
        }
val applozicChannelLeaveMember = ApplozicChannelLeaveMember(context, channelKey, userId, channelLeaveMemberListener) //pass channelKey and userId

Parameter

Description

channelKey

Unique identifier of the group/channel

userId

Unique identifier of the user

Then execute the task:

AlTask.execute(applozicChannelLeaveMember);
AlTask.execute(applozicChannelLeaveMember)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use applozicChannelLeaveMember.execute((Void)null); instead.

📘

Only a logged in user can leave a group.

Change Group Name

Make the following import:

import com.applozic.mobicomkit.uiwidgets.async.ApplozicChannelNameUpdateTask;

You can change the group name by creating a task as shown below:

ApplozicChannelNameUpdateTask.ChannelNameUpdateListener channelNameUpdateListener = new ApplozicChannelNameUpdateTask.ChannelNameUpdateListener() {
            @Override
            public void onSuccess(String response, Context context) {
                //Response will be "success" if Channel/Group name is changed successfully
                Log.i("ApplozicChannel", "Name update:" + response);
            }
            @Override
            public void onFailure(String response, Exception e, Context context) {

            }
        };

  ApplozicChannelNameUpdateTask channelNameUpdateTask = new ApplozicChannelNameUpdateTask(context, channelKey, channelName, channelNameUpdateListener);//pass context ,channelKey,chnanel new name
val channelNameUpdateListener: ChannelNameUpdateListener = object : ChannelNameUpdateListener {
            override fun onSuccess(response: String?, context: Context?) {
                //Response will be "success" if Channel/Group name is changed successfully
                if (!TextUtils.isEmpty(response)) {
                    Log.i("ApplozicChannel", "Name update:$response")
                }
            }

            override fun onFailure(response: String?, e: java.lang.Exception?, context: Context?) {}
        }

val channelNameUpdateTask = ApplozicChannelNameUpdateTask(context, channelKey, channelName, channelNameUpdateListener) //pass context ,channelKey,chnanel new name

Parameter

Description

channelKey

Unique identifier of the group/channel

userId

Unique identifier of the user

Then execute the task:

AlTask.execute(channelNameUpdateTask);
AlTask.execute(channelNameUpdateTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use channelNameUpdateTask.execute((Void) null); instead.

Group info task

You can use this below task to fetch the group information using client GroupId or groupId

AlGroupInformationAsyncTask.GroupMemberListener taskListener = new AlGroupInformationAsyncTask.GroupMemberListener() {
 @Override
 public void onSuccess(Channel channel, Context context) {
  // channel.getKey() this is groupId
 }

 @Override
 public void onFailure(Channel channel, Exception e, Context context) {

 }
};
AlGroupInformationAsyncTask groupInfoTask = new AlGroupInformationAsyncTask( < Your Context > , < ClientGroupId > , taskListener);
AlTask.execute(groupInfoTask);

List of Group members

Use the below code to get the list of group members in the group pass the channel key.

Note: This will give the data from a locally stored database.

List<ChannelUserMapper> listOfChannelUsers =  ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(<CHANNEL_KEY>);
    AppContactService appContactService = new AppContactService(context);
          for(ChannelUserMapper channelUserMapper :listOfChannelUsers ){

            // By using this channelUserMapper.getUserKey() userId you can get the contact  
           final Contact contact = appContactService.getContactById(channelUserMapper.getUserKey());

              Log.i("Member","UserId :"+ channelUserMapper.getUserKey());

              Log.i("Member","Role  :"+ channelUserMapper.getRole());

          }
val listOfChannelUsers = ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channelKey);

for (channelUserMapper in listOfChannelUsers) {
    Log.i("Member", "UserId :" + channelUserMapper.userKey)

    Log.i("Member", "Role  :" + channelUserMapper.role)
}

Mute/Un-mute Channel/Group (Stop Notifications)

Logged-in user can mute a group. You need to pass time in timestamp in UTC till you need to stop notifications from a particular group.
Create a MuteNotificationAsync task as shown below:

final MuteNotificationAsync.TaskListener taskListener = new MuteNotificationAsync.TaskListener() {
            @Override
            public void onSuccess(ApiResponse apiResponse) {
              //Muted successfull
            }

            @Override
            public void onFailure(ApiResponse apiResponse, Exception exception) {
               //Mute Failed
            }

            @Override
            public void onCompletion() {

            }
        };

//millisecond is the future timeStamp in UTC till you want to mute channel.
MuteNotificationRequest muteNotificationRequest = new MuteNotificationRequest(channel.getKey(), millisecond);
MuteNotificationAsync muteNotificationAsync = new MuteNotificationAsync(getContext(), taskListener, muteNotificationRequest);
val taskListener: MuteNotificationAsync.TaskListener = object : MuteNotificationAsync.TaskListener {
            override fun onSuccess(apiResponse: ApiResponse<*>?) {
                //Muted successfully
            }

            override fun onFailure(apiResponse: ApiResponse<*>?, exception: java.lang.Exception?) {
                //Mute Failed
            }

            override fun onCompletion() {}
        }
        
//millisecond is the future timeStamp in UTC till you want to mute channel.
val muteNotificationRequest = MuteNotificationRequest(channel.getKey(), millisecond)
val muteNotificationAsync = MuteNotificationAsync(context, taskListener, muteNotificationRequest)

Then execute the task using:

AlTask.execute(muteNotificationAsync);
AlTask.execute(muteNotificationAsync)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use muteNotificationAsync.execute((Void) null); instead.

-un-mute
To un-mute pass current time stamp in UTC in the above task.

Categorize groups chat conversation list

This section will guide you on how to create a group within some category where you can show only those group chat conversation based on some category name

You can check group create from this doc link

and the above group create AlChannelCreateAsyncTask set the channelInfo as below and pass the AL_CATEGORY value in Map

Map<String,String> channelMetaData =  new HashMap<>();
   channelMetaData.put("AL_CATEGORY","pass CATEGORY name ");

  channelInfo.setMetadata(channelMetaData); //Set the meta data
val channelMetaData: MutableMap<String, String> = HashMap()
channelMetaData["AL_CATEGORY"] = "pass CATEGORY name "

channelInfo.metadata = channelMetaData //Set the meta data

Also, set the Category name while launching the chat list screen paste this code before launching/starting a chat ConversationActivity and if you want some default Category chat conversation then in Login success of UserLoginTask you can set the below settings with a Category name

MobiComUserPreference.getInstance(context).setCategoryName("pass Category name  here ");
MobiComUserPreference.getInstance(context).categoryName = "pass Category name  here ";

Example while launching a chat list screen you need to pass Category name in setCategoryNameand start ConversationActivity

MobiComUserPreference.getInstance(context).setCategoryName("pass Category name  here ");

Intent intent = new Intent(this, ConversationActivity.class);            
startActivity(intent);
MobiComUserPreference.getInstance(context).categoryName = "pass Category name  here "
val intent = Intent(this, ConversationActivity::class.java)
startActivity(intent)

Context based chat in a group of two

These guides you on how to create and launch the context based chat using a group of two here. It will create a different thread conversation for a different topic with the same user.

Create a AlCreateGroupOfTwoTask:

List<String> channelMembersList = new ArrayList<String>();
            String userReceiverID = "<RECEIVER_USER_ID>"; //  pass receiver userID here
            channelMembersList.add(userReceiverID);
            String itemId = "<YOUR-ITEM_ID>"; // ID for item on which you want to initiate chat

            ChannelInfo channelInfo = new ChannelInfo("Context Based Group of Two", channelMembersList); //pass any name
            channelInfo.setType(Channel.GroupType.GROUPOFTWO.getValue().intValue()); //don't change this

            Map<String, String> metaData = new HashMap<>();
            metaData.put(Channel.GroupMetaDataType.TITLE.getValue(), "<YOUR-TITLE-HERE>"); //pass title here
            metaData.put(Channel.GroupMetaDataType.PRICE.getValue(), "<YOUR-ITEM-PRICE-HERE>"); //pass price
            metaData.put("AL_CONTEXT_BASED_CHAT", "true"); //pass price

            metaData.put(Channel.GroupMetaDataType.LINK.getValue(), "<YOUR-ITEM-IMAGE-URL-HERE>"); //pass image url here
            channelInfo.setMetadata(metaData);
           channelInfo.setClientGroupId(<YOUR-ITEM_ID>+"_"+<RECEIVER_USER_ID>);

            AlCreateGroupOfTwoTask.TaskListenerInterface createGroupOfTwoInterface = new AlCreateGroupOfTwoTask.TaskListenerInterface() {
                @Override
                public void onSuccess(Channel channel, Context context) {

                    // chat will be launched
                    Log.i("Client groupId:",channel.getClientGroupId());
                    Log.i("GroupId :",""+channel.getKey());
                    Intent takeOrderIntent = new Intent(context, ConversationActivity.class);
                    takeOrderIntent.putExtra(TAKE_ORDER, true);
                    takeOrderIntent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
                    takeOrderIntent.putExtra(ConversationUIService.GROUP_ID, channel.getKey());
                    startActivity(takeOrderIntent);
                }

                @Override
                public void onFailure(String error, Context context) {

                }
            };

            AlCreateGroupOfTwoTask channelCreateTask = new AlCreateGroupOfTwoTask(this, channelInfo, createGroupOfTwoInterface);
val channelMembersList: MutableList<String> = ArrayList()
val userReceiverID = "<RECEIVER_USER_ID>" //  pass receiver userID here
channelMembersList.add(userReceiverID)
val itemId = "<YOUR-ITEM_ID>" // ID for item on which you want to initiate chat

val channelInfo = ChannelInfo("Context Based Group of Two", channelMembersList) //pass any name

channelInfo.type = Channel.GroupType.GROUPOFTWO.value.toInt() //don't change this

val metaData: MutableMap<String, String> = HashMap()
    metaData[Channel.GroupMetaDataType.TITLE.value] = "<YOUR-TITLE-HERE>" //pass title here
    metaData[Channel.GroupMetaDataType.PRICE.value] = "<YOUR-ITEM-PRICE-HERE>"; //pass price
    metaData["AL_CONTEXT_BASED_CHAT"] = "true"; //pass price
    metaData[Channel.GroupMetaDataType.LINK.value] = "<YOUR-ITEM-IMAGE-URL-HERE>"; //pass image url here
channelInfo.metadata = metaData;
channelInfo.clientGroupId = < YOUR -ITEM_ID > +"_" + < RECEIVER_USER_ID >;

val createGroupOfTwoInterface: AlCreateGroupOfTwoTask.TaskListenerInterface = object : AlCreateGroupOfTwoTask.TaskListenerInterface {
            override fun onSuccess(channel: Channel, context: Context?) {

                // chat will be launched
                Log.i("Client groupId:", channel.getClientGroupId())
                Log.i("GroupId :", "" + channel.getKey())
                val takeOrderIntent = Intent(context, ConversationActivity::class.java)
                takeOrderIntent.putExtra(TAKE_ORDER, true)
                takeOrderIntent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true)
                takeOrderIntent.putExtra(ConversationUIService.GROUP_ID, channel.key)
                startActivity(takeOrderIntent)
            }

            override fun onFailure(error: String?, context: Context?) {}
        }

val channelCreateTask = AlCreateGroupOfTwoTask(this, channelInfo, createGroupOfTwoInterface)

Execute the task:

AlTask.execute(channelCreateTask);
AlTask.execute(channelCreateTask)

🚧

Note for older versions:

For SDK versions lesser than v5.95 use channelCreateTask.execute(); instead.

Updated 21 days ago


Groups


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.