Migration guide

MirrorFly Chat SDK Version 3 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 3.

Send Text Message#

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

FlyMessenger.sendTextMessage(TO_JID, TEXT, REPLY_MESSAGE_ID, MENTION_IDS, new SendMessageListener() {
@Override
public void onResponse(boolean isSuccess, @Nullable ChatMessage chatMessage) {
// you will get the message sent success response
}
});

Step 2: This method is newly introduced from Version 3, Add the following code to send the message.

TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
textMessage.setReplyMessageId(REPLY_MESSAGE_ID); // Optional
textMessage.setMentionedUsersIds(MENTION_IDS); // Optional
textMessage.setMetaData(META_DATA); //Optional
textMessage.setTopicId(TOPIC_ID); //Optional
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message obje ct to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Refer this doc to know more about Send Text Message

Send File Message#

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

Location Message#

FlyMessenger.sendLocationMessage(TO_JID, LATITUDE, LONGITUDE, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Contact Message#

FlyMessenger.sendContactMessage(TO_JID, CONTACT_NAME, CONTACT_NUMBERS, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Document Message#

FlyMessenger.sendDocumentMessage(TO_JID, FILE, FILE_NAME ,REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Video Message#

FlyMessenger.sendVideoMessage(TO_JID, FILE, CAPTION_TEXT, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Image message#

FlyMessenger.sendImageMessage(TO_JID, IMAGE_FILE, THUMBNAIL_BASE64, CAPTION, REPLY_MESSAGE_ID, MENTION_IDS, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Audio message#

FlyMessenger.sendAudioMessage(TO_JID, AUDIO_FILE, AUDIO_DURATION, IS_RECORDED, REPLY_MESSAGE_ID, (isSuccess, chatMessage) -> {
if (chatMessage != null) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Step 2: This method is newly introduced from Version 3, Add the following code to send the file messages.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
fileMessageParams.setCaption(CAPTION); //Optional
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.IMAGE);
fileMessage.setReplyMessageId(REPLY_MESSAGE_ID); //Optional
fileMessage.setMentionedUsersIds(MENTION_IDS); //Optional
fileMessage.setMetaData(META_DATA); //Optional
fileMessage.setTopicId(TOPIC_ID); //Optional
fileMessage.setFileMessage(fileMessageParams);
FlyMessenger.sendFileMessage(fileMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});

Refer this doc to know more about Send File Messages