Other chat features

Mute user/Group#

If you want to mute the notifications for the chat of a user or a group, you can utilise the below method.

ChatManager.shared.updateChatMuteStatus(jid: jid, muteStatus: muteStatus)
ArgumentTypeDescription
JIDStringjid of the chat user/ group
MUTE_STATUSBooltrue, if you want to mute notifications for the chat

Get Recent Chat#

To get the recent chat of a user or a group.

let recentChat = ChatManager.shared.getRecentChatOf(jid:jid)

Refer this doc to know more about RecentChat Class

ArgumentsTypeDescription
JIDStringjid of the user/group
caution

Will return a null object if a user never made a conversation with that user/group.

Get Recent Chat list#

To get the recent chat of a user or a group.

Mark a conversation as read#

By marking a converstaion as read the unread count will be reset and it is considered the message inside the conversation were read by you.

let recentChatList = ChatManager.shared.getRecentChatList()
or
ChatManager.shared.getRecentChatList { (isSuccess, flyError, resultDict) in
if (isSuccess) {
var recentChatList = resultDict
//update the UI
} else {
//Fetching recent chat list failed
}
}
ArgumentTypeDescription
CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler
info

The method with callback runs on background thread and the one without callback didn't run on background thread

Get Recent Chat list with archived chats#

To get the recent chat list including the arhived chat conversation call the below method.

let recentChatList = ChatManager.shared.getRecentChatListIncludingArchived()

Archive a recent chat conversation#

Archiving a chat conversation makes the chat not appear in recent chat list, mostly used on chats which are inactive for a long time.

ChatManager.shared.archiveChatConversation(jidsToArchive:jids)
ArgumentTypeDescription
JIDS_TO_ARCHIVE[String]jids of the user/group

Unarchive a archived recent chat conversation#

Unarchiving a archived recent chat conversation makes the chat conversation appear in recent chat list again.

ChatManager.shared.unarchiveChatConversation(jidsToUnarchive:jids)
ChatManager.markConversationAsRead(JID_LIST);
ArgumentTypeDescription
JIDS_TO_UNARCHIVE[String]jids of the user/group

Note : Archiving and Unarchiving a chat conversation persist in local only not across login or reinstalls.

Get List of archived recent chat conversation#

An archived chat won't be listed in recent chat list. To get the list of archived chats call the below method.

ChatManager.shared.getArchivedChatList { (isSuccess, flyError, resultDict) in
if isSuccess {
var flydata = resultDict
print(flydata.getData())
}else{
//Getting users blocked me list failed
}
}
ArgumentTypeDescription
CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

Mark a conversation as unread#

By marking a converstaion as unread it is considered the message inside the conversation were in unread state.

ChatManager.shared.getArchivedChatList { (isSuccess, flyError, resultDict) in
if isSuccess {
var flydata = resultDict
print(flydata.getData())
}else{
//Getting users blocked me list failed
}
}
ArgumentTypeDescription
CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler

Delete a Recent Chat#

To delete a recent chat of a user or a group call the method.

caution

If delete chat feature unavailable for your plan then below methods will throw 403 exception.

ChatManager.shared.deleteRecentChats(jids: JIDS)

We can delete a archived recent chat using this method too.

ArgumentsTypeDescription
JIDS[String]jid of the user/group
caution

Deleting a recent chat will delete the all the conversation for that user/group including favorite messages.

Pin a Recent Chat#

To pin a recent chat which makes a particular recent chat to appear at the top of the recent chat list.

ChatManager.shared.updateRecentChatPinStatus(jid: jid, pinRecentChat: pinRecentChat)
ArgumentsTypeDescription
JIDStringjid of the user/group
PIN_RECENT_CHATbooleanif true chat will be pinned else the chat will be unpinned

Recent Chat Pinned Count#

To get the pinned count on recent chat list call the below method.

let recentPinCount = ChatManager.shared.recentChatPinnedCount()

Clear chat messages#

Clear chat messages is a feature which allows users to delete the chat messages to reduce the storage usage. if you want to clear the messages for the entire chat, or multiple chats then you can utilise the below methods. it will also delete the downloaded media files from your local storage.

Clear chat#

You can clear the messages for any chat by using the below method. The messages will not be deleted to the receipient.

ChatManager.shared.clearChat(toJID: toJid, chatType: chatType, clearChatExceptStarred: clearChatExceptStarred) { (isSuccess, flyerror, resultDict) in
}
ArgumentTypeDescription
TO_JIDStringjid of the chat user
CHAT_TYPEChatTypeEnumChatTypeEnum.chat for single chat, ChatTypeEnum.groupchat for group chat, ChatTypeEnum.broadcast for broadcast
CLEAR_EXCEPT_STARREDbooleanif true, delete all the messages except the favourite messages
CALLBACKFlyCompletionHandlerFlyCompletionHandler used as completion Handler