Single chat

note

To generate your own or others JID using the unique username got in registration response, use the const userJid = SDK.getJid(USER_ID) method.

Get Chat Messages#

To get the chat history of the selected user, send a request to the server as described below.

await SDK.getChatMessages(
toJid: ""
);

Example

await SDK.getChatMessages(
toJid: "91XXXXXXXXXX@domain.com",
);

Request Params#

StatusDescriptionTypeRequired
toJidJID of the To User/GroupJID Stringtrue

Response Format#

{
statusCode: 200,
message: "Success",
userJid: "", // String - Requested User Jid
"data": [
{
"createdAt": "",//String - Message Created Time
"chatType": "chat",
"favouriteBy": "",
"favouriteStatus": 0,
"deleteStatus": 0, // Number - changes to 1 when deleteforMe and 2 when deleteForEveryone
"fromUserJid": "",// string -fromUserJid
"publisherJid": "",// string -publisherJid
"publisherId": "",// string -publisherId
"timestamp": "",//number- timestamp
"msgId": "",//string - msgId
"msgStatus": 1,
"msgBody": {
"nickName": "",
"mid": "",//string - msgId
"message": "",//string - send media message
"message_type": "text",
"replyTo": "",
"mentionedUsersIds": ""
}
},
{
"createdAt": "2023-09-07 06:35:23",
"chatType": "chat",
"favouriteBy": "",
"favouriteStatus": 0,
"deleteStatus": "", // Number - changes to 1 when deleteforMe and 2 when deleteForEveryone
"fromUserId": "", // String - From User Id
"fromUserJid": "",// String - fromUserJid
"publisherJid": "",// String - publisherJid
"publisherId": "",// String - mobile Number publisherJid
"timestamp": "",// number- timestamp
"msgId": "",// String - msgId
"msgStatus": 1,// Number - msgStatus
"msgBody": {
"nickName": "",//String - UserName
"media": {
"androidHeight": "",//Number - androidHeight
"androidWidth": "",//Number - androidWidth
"caption": "",
"duration": 0,
"fileName": "",//string fileName
"file_key": "",
"file_url": "",//string - File format file_url
"file_size": 139791,
"is_downloaded": 0,
"is_uploading": 2,
"local_path": "",//string - File format local_path
"msgId": "",//string - msgId
"originalHeight": 0,
"originalWidth": 0,
"thumb_image": "",
"webWidth": "",//Number - webWidth
"webHeight": "",//Number - webHeight
"fileType": "image/jpeg" //string -File format
},
"mid": "98b05f38-5f42-42fc-9313-be84793b3312",//string -mid
"message": "",//string - media message
"message_type": "image",
"replyTo": "",
"mentionedUsersIds": ""
}
}
]
}

Download Media#

This method is used to get the media file url when we download the media.

await SDK.getMediaURL(`fileToken`);

Request Param#

StatusDescriptionTypeRequired
fileTokenFile UrlStringtrue

Example Requests#

await SDK.getMediaURL("9178680804311682318992048B1cCBm6F6WIVI38s9r1a.mp4");

Response Format#

{
"data": {
"fileUrl": "",// String - image Url
"token": "" // // String - image Token
},
"message": "",// String - Success/Error Message
"statusCode": "" // Number - status code,
}