Mention

To Mention user along with a message in a group, you can use mentionedUsersIds param provided to all kinds of messages such as Text, Image, video.

Text message#

To send your text message, you need to pass the TextMessage object as an argument to the parameter in the sendTextMessage() method.

TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
textMessage.setMentionedUsersIds(MENTION_IDS);
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSTextMessageObject to hold the parameters of the text message
CALLBACKSendMessageCallbackcallback to observe the action status

Image message#

To send your image message, you need to pass the FileMessage object as an argument to the parameter in the sendFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
fileMessageParams.setCaption(CAPTION);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.IMAGE);
fileMessage.setMentionedUsersIds(MENTION_IDS);
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
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the image message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Image attachment feature unavailable for your plan then it will throw 403 exception.

Image message with url#

To send your image message, you need to pass the FileMessage object as an argument to the parameter in the sendFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileName(FILE_NAME);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
fileMessageParams.setThumbImage(THUMB_IMAGE);
fileMessageParams.setCaption(CAPTION);
FileMessage sendMessageParams = new FileMessage();
sendMessageParams.setToId(TO_JID);
sendMessageParams.setMessageType(MessageType.IMAGE);
sendMessageParams.setMentionedUsersIds(MENTION_IDS);
sendMessageParams.setFileMessage(fileMessageParams);
FlyMessenger.sendFileMessage(sendMessageParams, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the image message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Image attachment feature unavailable for your plan then it will throw 403 exception.

Video message#

To send your video message, you need to pass the FileMessage object as an argument to the parameter in the sendFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFile(FILE);
fileMessageParams.setCaption(CAPTION);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.VIDEO);
fileMessage.setMentionedUsersIds(MENTION_IDS);
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
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the video message
CALLBACKSendMessageCallbackcallback to observe the action status

Note : In ChatManager .setMediaFolderName should be defined to set your own local path to store app media files.

caution

If Video attachment feature unavailable for your plan then it will throw 403 exception.

Video message with url#

To send your video message, you need to pass the FileMessage object as an argument to the parameter in the sendFileMessage() method.

FileMessageParams fileMessageParams = new FileMessageParams();
fileMessageParams.setFileUrl(FILE_URL);
fileMessageParams.setFileName(FILE_NAME);
fileMessageParams.setFileSize(FILE_SIZE);
fileMessageParams.setLocalFilePath(LOCAL_FILE_PATH);
fileMessageParams.setThumbImage(THUMB_IMAGE);
fileMessageParams.setDuration(DURATION);
fileMessageParams.setCaption(CAPTION);
FileMessage fileMessage = new FileMessage();
fileMessage.setToId(TO_JID);
fileMessage.setMessageType(MessageType.VIDEO);
fileMessage.setMentionedUsersIds(MENTION_IDS);
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
}
});
ArgumentTypeDescription
MESSAGE_PARAMSFileMessageObject to hold the parameters of the video message
CALLBACKSendMessageCallbackcallback to observe the action status
caution

If Video attachment feature unavailable for your plan then it will throw 403 exception.

Send Reply message#

To send reply message to the original message, you need to pass the additional parameter original message-id in replyMessageId.TextMessage object as an argument to the parameter in the sendTextMessage() method.

TextMessage textMessage = new TextMessage();
textMessage.setToId(TO_JID);
textMessage.setMessageText(TEXT);
textMessage.setReplyMessageId(REPLY_MESSAGE_ID);
textMessage.setMentionedUsersIds(MENTION_IDS);
FlyMessenger.sendTextMessage(textMessage, (isSuccess, error, chatMessage) -> {
if (isSuccess) {
//you can add this message object to your arraylist,
//then you can call notifyItemInserted in adapter of recycler view
}
});
ArgumentTypeDescription
MESSAGE_PARAMSTextMessageObject to hold the parameters of the text message
CALLBACKSendMessageCallbackcallback to observe the action status

Receive Message#

To receive a mentioned related message from another user in a group, you must implement the messageListener function. It’s a function that will be triggered whenever you receive a new message or related event in the chat.

fun onMessageReceived(ChatMessage message) {
}
info

To learn more on message listener callbacks, see the MessageEventsCallbacks.