Retrieve Recent Chats

Get Recent Chats#

To get all the list of recent chats, send a request to the server as described below.

await SDK.getRecentChats();

Response Params#

ArgumentsDescriptionType
statusCodeStatus CodeNumber
messageSuccess/Error MessageString
dataArray of Object datasArray

Response Format:#

{
"statusCode": 200,
"message": "Success",
"data": [
{
"chatType": "chat", // String - Chat Type "chat"/"groupchat"
"createdAt": "2024-04-02 10:38:02.350", // String - Created Time
"recallStatus": 0, // Number - changes to 1 when deleteForEveryone
"deleteStatus": 0, // Number - changes to 1 when deleteforMe
"fromUserId": "", // String - From User Id
"fromUserJid": "user@domain",
"toUserJid": "",
"msgBody": {
"message": "Hi", // String - Message Body
"message_type": "text", // String - Message Type
"replyTo": "",
"notificationContent": "You added wjksd3kwwsz8fbmggtujq9ahu4u2" // For only groupchat and message_type ['notification']
"nickName": "" // String - User Name
"media": { // For Media Message Only for message_type ['image', 'video', 'file', 'audio']
"androidHeight": 188, // Number - Android Height -Only For Image/Video
"androidWidth": 250, // Number - Android Width -Only For Image/Video
"caption": "", // String - Media Caption
"duration": 0, // Number - Duration - For Audio/Videos
"fileName": "", // String - File Name
"file_key": "", // String - File Key
"file_size": 543879, // Number - File Size
"file_url": "", // String - File Url
"is_downloaded": 0, // Number - Downloaded Status
"is_uploading": 2, // Number - Uploading Status
"local_path": "", // String - Local Path
"msgId": "", // String - MessageId
"originalHeight": 240, // Number - Original Height -Only For Image/Video
"originalWidth": 320, // Number - Original Width -Only For Image/Video
"thumb_image": "", // Base64 - Thumb Image
"webHeight": 248, // Number - Web Height -Only For Image/Video
"webWidth": 330 // Number - Web Width -Only For Image/Video
},
"contact": { // For Contact Message Only ['contact']
"mid": "fc524a2f-a342-4c94-827d-e89d0a865503",
"name": "",
"phone_number": [""],
"active_status": ["0"]
}
"location": { // For Location Message Only ['location']
"mid": "0554ca74-a5c0-4bcc-8cb3-01055d033337",
"latitude": "13.0122057",
"longitude": "80.2094575"
}
},
"msgId": "878aef37-8e14-4e97-aa19-e5f391179d89", // String - Unique Message Id
"msgStatus": 0, // Number - Message Status
"muteStatus": 0, // Number - Mute Status
"publisherId": "sender", // String - Publisher Id
"publisherJid": "sender@domain",
"timestamp": 1712054282350, // Number - TimeStamp - Milliseconds
"unreadCount": 0, // Number - Unread Message Count
"isUnread": 0, // 0 or 1, if the chat have unread messages 1 else 0
"userId": "chat user",
"userJid": "chatUser@domain",
"profileDetails": {
"nickName": "", // String - User Name
"image": "", // String - image
"status": "", //String - User status
"colorCode": "#7b0b88",
"userId": "", // String - userId
"userJid": "", // String - userJid
"email": "", //String - User Email-Id
"mobileNumber": "", //String - User mobile number
"isAdminBlocked": 0
}
"userType": "o" // For only groupchat, loggedin user current status of the group,
// "o" - Admin / "n" - Particiapant / "" - left or removed user (Empty)
},
]
}

Note: To handle notification types in UI click here