Chat Room and Messages - TapCore

If you are using core implementation method, you can use the methods from the TapCoreChatRoomManager and TapCoreMessageManager class to manage chat room and messages.
TapTalk Chat Method
Description
Returns the room model of the currently active chat room.
Create new personal chat room with recipient user, or obtain chat room data if it already exists
Create new personal chat room with recipient user ID, or obtain chat room data if it already exists.
Create a new group chat room with selected group name.
Create a new group chat room with selected group name and group picture.
Get group room data from selected group room ID.
Update existing group chat room data.
Update group picture with current selected image.
Delete group chat room from the device's local storage.
Delete group chat room and clear all chat data and participants.
Leave from selected group chat.
Add selected member(s) to current group chat room.
Remove selected member(s) from current group chat room.
Promote selected member(s) as admin(s) to the current group chat room.
Demote selected admin(s) to member(s) to the current group chat room.
Obtain Saved Messages chat room data
Notify that the active user has started typing in the selected room.
Notify that the active user has stopped typing in the selected room.
Send a new text message to the selected chat room.
Send a new message with location to the selected chat room.
Send a new image message to the selected chat room.
Send a new video message to the selected chat room.
Send a new file message to the selected chat room.
Send a new voice message to the selected chat room.
Send a new link message to the selected chat room.
Forward existing messages to the selected chat room.
Construct a customized TapTalk.io message model.
Send a new custom message to the room defined in the message model.
Edit the contents of the selected message.
Delete the selected message from the server.
Delete the selected message from local storage.
Cancel image, video, or file upload on the selected pending message.
Start a file download from the selected file, image, or video message.
Cancel image, video, or file download on the selected message.
Mark message as delivered by the active user.
Mark message as read by the active user.
Mark all unread messages in a chat room as read.
Retrieve messages from chat room that are already stored in the device's local storage.
Retrieve messages that are older than the provided timestamp from the server to the selected chat room.
Retrieve newer messages from the server to the selected chat room
Retrieve all available messages from the selected chat room.
Retrieve unread messages from the device's local storage.
Retrieve media messages from the device's local storage.
Call this method to search messages from the device's local storage with a keyword.
Set message as starred or remove star from message for the active user.
Retrieve list of messages marked as starred in a chat room.
Set message as pinned or remove pin from message for all room participants.
Retrieve list of pinned messages in a chat room.
Retrieve image, video, file, and link messages from a chat room.
Clear all existing messages in a selected chat room for the active user.
Schedule a message to be delivered at a specified time.
Retrieve list of created scheduled messages in a chat room.
Send a previously created scheduled message immediately to the recipient.
Change the deliver time of a previously created scheduled message.
Update the contents of a scheduled message that has not been delivered.
Delete a scheduled message that has not been delivered.

Get Active Chat Room

Returns the room model (TAPRoomModel) of the currently active chat room.
Java
Kotlin
TAPRoomModel activeRoom = TapCoreChatRoomManager.getInstance().getActiveChatRoom();
val room = TapCoreChatRoomManager.getInstance().activeChatRoom

Get Personal Chat Room with Recipient User

Create new personal chat room with recipient user, or obtain chat room data if it already exists.
Java
Kotlin
TapCoreChatRoomManager.getInstance().getPersonalChatRoom(RECIPIENT_USER, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Open chat room here
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().getPersonalChatRoom(RECIPIENT_USER, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Open chat room here
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters RECIPIENT_USER: (TAPUserModel) recipient user data

Get Personal Chat Room with Recipient User ID

Create new personal chat room with recipient user ID, or obtain chat room data if it already exists.
Java
Kotlin
TapCoreChatRoomManager.getInstance().getPersonalChatRoom(RECIPIENT_ID, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Open chat room here
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().getPersonalChatRoom(RECIPIENT_ID, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Open chat room here
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters RECIPIENT_ID: (String) user ID of recipient

Create Group Chat Room

Create a new group chat room with selected group name.
Java
Kotlin
TapCoreChatRoomManager.getInstance().createGroupChatRoom(GROUP_NAME, PARTICIPANT_LIST, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Group chat room created successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().createGroupChatRoom(GROUP_NAME, PARTICIPANT_LIST, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Group chat room created successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_NAME: (String) your group name PARTICIPANT_LIST: (List) list of the group participant's user IDs

Create Group Chat Room

Create a new group chat room with selected group name and group picture.
Java
Kotlin
TapCoreChatRoomManager.getInstance().createGroupChatRoomWithPicture(GROUP_NAME, PARTICIPANT_LIST, IMAGE_URI, new TapCoreCreateGroupWithPictureListener() {
@Override
public void onSuccess(TAPRoomModel room, boolean isPictureUploadSuccess) {
// Group chat room created successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().createGroupChatRoomWithPicture(GROUP_NAME, PARTICIPANT_LIST, IMAGE_URI, object : TapCoreCreateGroupWithPictureListener() {
override fun onSuccess(room: TAPRoomModel?, isPictureUploadSuccess: Boolean) {
// Group chat room created successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_NAME: (String) name of the group chat room to create PARTICIPANT_LIST: (List) list of the group participant's user IDs IMAGE_URI: (Uri) picture to be uploaded as the group's profile

Get Group Chat Room

Get group room data from selected group room ID.
Java
Kotlin
TapCoreChatRoomManager.getInstance().getGroupChatRoom(GROUP_ID, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Open chat room here
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().getGroupChatRoom(GROUP_ID, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Open chat room here
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of group

Update Group Chat Room Details

Create a new Update existing group chat room data.
Java
Kotlin
TapCoreChatRoomManager.getInstance().updateGroupChatRoomDetails(GROUP_ID, GROUP_NAME, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Updated group chat room successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().updateGroupChatRoomDetails(GROUP_ID, GROUP_NAME, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Updated group chat room successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of group GROUP_NAME: (String) name of group

Update Group Image

Update group picture with current selected image.
Java
Kotlin
TapCoreChatRoomManager.getInstance().updateGroupPicture(GROUP_ID, IMAGE_URI, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Updated group chat room successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().updateGroupPicture(GROUP_ID, IMAGE_URI, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Updated group chat room successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group IMAGE_URI: (Uri) new picture for the group's profile

Delete Local Group Chat Room

Delete group chat room from the device's local storage and clear all chat data and participants. Locally deleted room data will still be accessible from the server if the user remains a participant in the room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().deleteLocalGroupChatRoom(ROOM_ID, new TapCommonListener() {
@Override
public void onSuccess(String successMessage) {
// Deleted group chat room successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().deleteLocalGroupChatRoom(ROOM_ID, object : TapCommonListener() {
override fun onSuccess(successMessage: String?) {
// Deleted group chat room successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters ROOM_ID: (String) group room ID to be deleted

Delete Group Chat Room

Delete group chat room and clear all chat data and participants.
Java
Kotlin
TapCoreChatRoomManager.getInstance().deleteGroupChatRoom(GROUP_CHAT_MODEL, new TapCommonListener() {
@Override
public void onSuccess(String successMessage) {
// Deleted group chat room successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().deleteGroupChatRoom(GROUP_CHAT_MODEL, object : TapCommonListener() {
override fun onSuccess(successMessage: String?) {
// Deleted group chat room successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_CHAT_MODEL: (TAPRoomModel) a room model of the group to delete

Leave Group Chat

Leave from selected group chat.
Java
Kotlin
TapCoreChatRoomManager.getInstance().leaveGroupChatRoom(GROUP_ID, new TapCommonListener() {
@Override
public void onSuccess(String successMessage) {
// Left chat room successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().leaveGroupChatRoom(GROUP_ID, object : TapCommonListener() {
override fun onSuccess(successMessage: String?) {
// Left chat room successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group

Add Members to Group Chat

Add selected member(s) to current group chat room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().addGroupChatMembers(GROUP_ID, USER_IDs, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Added group members successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().addGroupChatMembers(GROUP_ID, USER_IDs, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Added group members successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group USER_IDs: (List) list of the user IDs to add to the group

Remove Members from Group Chat

Remove selected member(s) from current group chat room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().removeGroupChatMembers(GROUP_ID, USER_IDs, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Removed members successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().removeGroupChatMembers(GROUP_ID, USER_IDs, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Removed members successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group USER_IDs: (List) list of the user IDs to add to the group

Promote Group Admin

Promote selected member(s) as admin(s) to the current group chat room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().promoteGroupAdmins(GROUP_ID, USER_IDs, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Promoted admins successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().promoteGroupAdmins(GROUP_ID, USER_IDs, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Promoted admins successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group USER_IDs: (List) list of the user IDs to add to the group

Demote Group Admin

Demote selected admin(s) to member(s) to the current group chat room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().demoteGroupAdmins(GROUP_ID, USER_IDs, new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Demoted admins successfully
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().demoteGroupAdmins(GROUP_ID, USER_IDs, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Demoted admins successfully
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})
Parameters GROUP_ID: (String) room ID of the selected group USER_IDs: (List) list of the user IDs to add to the group

Get Saved Messages Chat Room

Obtain Saved Messages chat room data.
Java
Kotlin
TapCoreChatRoomManager.getInstance(instanceKey).getSavedMessagesChatRoom(new TapCoreGetRoomListener() {
@Override
public void onSuccess(TAPRoomModel room) {
// Open chat room here
}
@Override
public void onError(String errorCode, String errorMessage) {
}
});
TapCoreChatRoomManager.getInstance().getPersonalChatRoom(RECIPIENT_ID, object : TapCoreGetRoomListener() {
override fun onSuccess(room: TAPRoomModel?) {
// Open chat room here
}
override fun onError(errorCode: String?, errorMessage: String?) {
}
})

Send Start Typing

Notify that the active user has started typing in the selected room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().sendStartTypingEmit(ROOM_ID);
TapCoreChatRoomManager.getInstance().sendStartTypingEmit(ROOM_ID)
Parameters ROOM_ID: (String) ID of the room where the user starts typing in

Send Stop Typing

Notify that the active user has stopped typing in the selected room.
Java
Kotlin
TapCoreChatRoomManager.getInstance().sendStopTypingEmit(ROOM_ID);
TapCoreChatRoomManager.getInstance().sendStopTypingEmit(ROOM_ID)
Parameters ROOM_ID: (String) ID of the room where the user starts typing in

Send Text Message

To send a text message to a chat room, use the sendTextMessage() method from the TapCoreMessageManager class.
Java
Kotlin
TapCoreMessageManager.getInstance().sendTextMessage(MESSAGE_BODY, ROOM, new TapCoreSendMessageListener() {
@Override
public void onStart(TAPMessageModel message) {
// Message was constructed
}
@Override
public void onSuccess(TAPMessageModel message) {
// Message was sent successfully
}
@Override
public void onError(@Nullable TAPMessageModel message, String errorCode, String errorMessage) {
}
});
TapCoreMessageManager.getInstance().sendTextMessage(MESSAGE_BODY, ROOM, object : TapCoreSendMessageListener() {
override fun onStart(message: TAPMessageModel?) {
// Message was constructed
}
override fun onSuccess(message: TAPMessageModel?) {
// Message was sent successfully
}
override fun onError(message: TAPMessageModel?, errorCode: String?, errorMessage: String?) {
}
})
Use the sendTextMessage() method with extra parameter to send a text message with quote.
Java
Kotlin
TapCoreMessageManager.getInstance().sendTextMessage(MESSAGE_BODY, ROOM, QUOTED_MESSAGE, new TapCoreSendMessageListener() {
@Override
public void onStart(TAPMessageModel message) {
// Message was constructed
}
@Override
public void onSuccess(TAPMessageModel message) {
// Message was sent successfully
}
@Override
public void onError(@Nullable TAPMessageModel message, String errorCode, String errorMessage) {
}
});
TapCoreMessageManager.getInstance().sendTextMessage(MESSAGE_BODY, ROOM, QUOTED_MESSAGE, object : TapCoreSendMessageListener() {
override fun onStart(message: TAPMessageModel?) {
// Message was constructed
}
override fun onSuccess(message: TAPMessageModel?) {
// Message was sent successfully
}
override fun onError(message: TAPMessageModel?, errorCode: String?, errorMessage: String?) {
}
})
Parameters MESSAGE_BODY: (String) content of the message ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message

Send Location Message

You can send a location embedded in a chat message using sendLocationMessage(). This method takes latitude, longitude, and address text as parameters.
Java
Kotlin
TapCoreMessageManager.getInstance().sendLocationMessage(LATITUDE, LONGITUDE, ADDRESS, ROOM, new TapCoreSendMessageListener() {
@Override
public void onStart(TAPMessageModel message) {
// Message was constructed
}
@Override
public void onSuccess(TAPMessageModel message) {
// Message was sent successfully
}
@Override
public void onError(@Nullable TAPMessageModel message, String errorCode, String errorMessage) {
}
});
TapCoreMessageManager.getInstance().sendLocationMessage(LATITUDE, LONGITUDE, ADDRESS, ROOM, object : TapCoreSendMessageListener() {
override fun onStart(message: TAPMessageModel?) {
// Message was constructed
}
override fun onSuccess(message: TAPMessageModel?) {
// Message was sent successfully
}
override fun onError(message: TAPMessageModel?, errorCode: String?, errorMessage: String?) {
}
})
Use the sendLocationMessage() method with extra parameter to send a location message with quote.
Java
Kotlin
TapCoreMessageManager.getInstance().sendLocationMessage(LATITUDE, LONGITUDE, ADDRESS, ROOM, QUOTED_MESSAGE, new TapCoreSendMessageListener() {
@Override
public void onStart(TAPMessageModel message) {
// Message was constructed
}
@Override
public void onSuccess(TAPMessageModel message) {
// Message was sent successfully
}
@Override
public void onError(@Nullable TAPMessageModel message, String errorCode, String errorMessage) {
}
});
TapCoreMessageManager.getInstance().sendLocationMessage(LATITUDE, LONGITUDE, ADDRESS, ROOM, QUOTED_MESSAGE, object : TapCoreSendMessageListener() {
override fun onStart(message: TAPMessageModel?) {
// Message was constructed
}
override fun onSuccess(message: TAPMessageModel?) {
// Message was sent successfully
}
override fun onError(message: TAPMessageModel?, errorCode: String?, errorMessage: String?) {
}
})
Parameters LATITUDE: (Double) latitude of the shared location LONGITUDE: (Double) longitude of the shared location ADDRESS: (String) text data containing the location address ROOM: (TAPRoomModel) the destination room where the message will be sent QUOTED_MESSAGE: (TAPMessageModel) quote containing another existing message

Send Image Message

To send an image to a chat room, you can use sendImageMessage() method by providing either IMAGE_URI or BITMAP as parameter.
Java
Kotlin
// Send image with file Uri
TapCoreMessageManager.getInstance().sendImageMessage(IMAGE_URI, CAPTION, ROOM, new TapCoreSendMessageListener() {
@Override
public void onStart(TAPMessageModel message) {
// Message was constructed
}
@Override
public void onProgress(TAPMessageModel message, int percentage, long bytes) {
// Image upload is in progress
}
@Override
public void onSuccess(TAPMessageModel message) {
// Message was sent successfully
}
@Override
public void onError(@Nullable