Migration guide

MirrorFly Chat SDK Version 2 has introduced major send message method changes to streamline the code structure and enhance its scalability. This guide explains step by step guide for migrating to Version 2 from Version 1.

Send Text Message#

Instead of getting params as method parameters, we have introduced single object param with all input data. To reduce the complexity in getting params.

Step 1: Params of the below method were updated from Version 2.

await SDK.sendTextMessage(`TO_USER_JID`, `MESSAGE_BODY`, `MESSAGE_ID`, `REPLY_TO`, `MENTIONED_USERS_IDS`);

Step 2: Update the following method with the new updated params in the code.

await SDK.sendTextMessage({
toJid: "",
messageText: "",
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});

Send Media/File Messages#

We have introduced common method to send all type media/file messages. To reduce the integration time.

Step 1: Below methods were deprecated from Version 2, Remove the following method from the code.

await SDK.sendImageMessage(`TO_USER_JID`, `IMAGE_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
await SDK.sendAudioMessage(`TO_USER_JID`, `AUDIO_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
await SDK.sendVideoMessage(`TO_USER_JID`, `VIDEO_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
await SDK.sendDocumentMessage(`TO_USER_JID`, `DOCUMENT_FILE`, `FILE_OPTIONS`, `REPLY_TO`, `MENTIONED_USERS_IDS`);
await SDK.sendMediaMessageData(`TO_USER_JID`, `MSG_TYPE`, `FILE_OPTIONS`, `MSG_ID`, `REPLY_TO`, `MENTIONED_USERS_IDS`);

Step 2: Update to the following method with the latest parameters.

await SDK.sendFileMessage({
toJid: "",
messageType: "image" //image/video/audio/file
fileMessageParams: {
file: {}, // Or fileUrl = "" (You can also send a file message with a file URL.)
thumbImage: "",
fileSize: 0,
fileName: "",
caption: "",
},
replyMessageId: "",
mentionedUsersIds: [],
topicId: "",
metaData: {}
});

Here, based on the messageType SDK will determine the type of message and process it.

Refer Here to know more about Send File Message method.

Get Chat Messages#

Instead of getting params as getChatMessages method parameters, we have introduced single object param with all input data. To reduce the complexity in getting params.

Step 1: Params of the below method were updated from Version 2.

await SDK.getChatMessages(`TO_JID`, `POSITION`, `LAST_ROW_ID`, `LIMIT`, `TOPIC_ID`);

Step 2: Update the following method with the new updated params in the code.

await SDK.getChatMessages({
toJid: "",
position: "",
lastRowId: "",
limit: "",
topicId: ""
});

Refer Here to know more about Get Chat Messages method.

Get Media Messages#

Instead of getting params as getMediaMessages method parameters, we have introduced single object param with all input data. To reduce the complexity in getting params.

Step 1: Params of the below method were updated from Version 2.

await SDK.getMediaMessages(`TO_USER_JID`, `LAST_MESSAGE_ID`, `TOPIC_ID`);

Step 2: Update the following method with the new updated params in the code.

await SDK.getMediaMessages({
toJid: "",
lastMsgId: "",
topicId: ""
});

Refer Here to know more about Get Media Messages method.