Class RongIMClient
-
- All Implemented Interfaces:
public abstract class RongIMClient
Core class for the IM client. All IM-related methods and listeners are invoked and configured here. Can only be called in the main process.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public enum
RongIMClient.TimestampOrder
public enum
RongIMClient.ConnectionErrorCode
*Error Codes for Connection Establishment**
public enum
RongIMClient.ErrorCode
RongIMClient ErrorCode
public enum
RongIMClient.DatabaseOpenStatus
Database Open Enumeration
public enum
RongIMClient.MediaType
File type enumeration.
public enum
RongIMClient.BlacklistStatus
Indicates whether the user is in the blocklist.
public enum
RongIMClient.SearchType
Search type enumeration.
public enum
RongIMClient.PushLanguage
Remote Notification Language Type
public enum
RongIMClient.DiscussionInviteStatus
Discussion group invitation status.
public interface
RongIMClient.EncryptedSessionConnectionListener
Listens for the establishment status of encrypted session signaling.
Initiated by: onEncryptedSessionRequest Responded by: onEncryptedSessionResponse Established successfully: onEncryptedSessionEstablished Canceled encrypted session: onEncryptedSessionCanceled Terminated encrypted session: onEncryptedSessionTerminated
public interface
RongIMClient.ConnectionStatusListener
Connection state listener, which retrieves connection-related status.
public interface
RongIMClient.OnReceiveMessageListener
Listener for receiving messages. Note: Switch threads for time-consuming operations.
public interface
RongIMClient.TypingStatusListener
Typing status listener that triggers a callback when the typing status changes.
public interface
RongIMClient.RCLogInfoListener
*Log Output Monitoring**
public interface
RongIMClient.ReadReceiptListener
Message receipt listener.
Triggers the onReadReceiptReceived callback when a message receipt is received.
public interface
RongIMClient.OnReceiveDestructionMessageListener
Listener for Burn After Reading Message Reception
public interface
RongIMClient.OnRecallMessageListener
Message Recall Listener
public interface
RongIMClient.SyncConversationReadStatusListener
Listener interface for synchronizing unread message status.
When logged in on multiple devices, this callback
onSyncConversationReadStatus
is triggered upon receiving a notification from another device that clears the unread count of a specific conversation.public interface
RongIMClient.DestructCountDownTimerListener
! Callback interface for countdown to incineration.
public interface
RongIMClient.ConversationStatusListener
Conversation Status (Pin and Do Not Disturb) Multi-Device Synchronization Monitoring
public interface
RongIMClient.MessageExpansionListener
public interface
RongIMClient.ChatRoomActionListener
Chatroom Operation Listener
public interface
RongIMClient.KVStatusListener
Listens for changes in chatroom KV status
public interface
RongIMClient.RealTimeLocationListener
Real-time location sharing listener.
public class
RongIMClient.DefaultOperationCallback
public abstract class
RongIMClient.Callback
public abstract class
RongIMClient.ResultCallback
A generic class for handling callback functionality in APIs.
public abstract class
RongIMClient.ConnectCallback
Callback class for server connection.
public abstract class
RongIMClient.SyncCallback
public abstract class
RongIMClient.OperationCallback
Operation execution callback.
public abstract class
RongIMClient.OnReceiveMessageWrapperListener
Listener for receiving messages. Note: Switch threads to handle time-consuming operations.
This interface can replace OnReceiveMessageListener to address the issue of frequent UI refreshes when receiving a large number of messages. The interface returns the `left` and `hasPackage` parameters, which can be used together to determine when all offline messages have been fetched.
public abstract class
RongIMClient.SendMessageCallback
Callback for sending messages.
public abstract class
RongIMClient.SendImageMessageWithUploadListenerCallback
Callback for sending image messages.
Use this callback if you need to upload the image to your own server.
public abstract class
RongIMClient.SendImageMessageCallback
Callback for sending an image message.
public abstract class
RongIMClient.SendMediaMessageCallback
Callback for sending multimedia messages.
public abstract class
RongIMClient.UploadMediaCallback
Callback for uploading media files.
public abstract class
RongIMClient.DownloadMediaCallback
*Callback for file download.**
public abstract class
RongIMClient.GetNotificationQuietHoursCallback
Callback for retrieving the Do Not Disturb time settings for message notifications.
public abstract class
RongIMClient.GetBlacklistCallback
Get blocklist callback.
public abstract class
RongIMClient.CreateDiscussionCallback
Callback for creating a discussion group.
public class
RongIMClient.UploadImageStatusListener
Monitors the status of image upload.
If the user uploads images independently, the upload progress should be updated and displayed on the UI by calling methods in UploadImageStatusListener. This listener is returned as an instance through SendImageMessageWithUploadListenerCallback for the user's use.
-
Constructor Summary
Constructors Constructor Description RongIMClient()
-
Method Summary
Modifier and Type Method Description static RongIMClient
getInstance()
Obtains an instance of the IMLib interface class. static void
init(Application application, String appKey)
Initializes the RCSDK. static void
init(Context context)
Initializes the SDK. static void
init(Context context, String appKey)
Initializes the SDK. static void
init(Context context, String appKey, boolean enablePush)
Initializes the SDK. static void
init(Context context, String appKey, boolean enablePush, Boolean isMainProcess)
Initializes the SDK. static RongIMClient
connect(String token, RongIMClient.ConnectCallback connectCallback)
Connects to the RCserver. static RongIMClient
connect(String token, int timeLimit, RongIMClient.ConnectCallback connectCallback)
Connects to the RCserver. static String
getVersion()
static void
setConnectionStatusListener(RongIMClient.ConnectionStatusListener listener)
Sets a listener for connection status changes. static void
setOnReceiveMessageListener(OnReceiveMessageListener listener)
Sets the listener for receiving message events. static boolean
addOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Adds a listener for the message received event. static boolean
removeOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Removes the listener for the message received event. static void
registerMessageType(Class<out MessageContent> messageContentClass)
Register custom message types Call this method after initialization but before connecting to register custom messages. static void
registerMessageType(List<Class<out MessageContent>> messageContentClassList)
Batch register custom message types Call this method to register custom messages after initialization and before connection. static void
setTypingStatusListener(RongIMClient.TypingStatusListener listener)
Sets the typing status listener. static void
setRCLogInfoListener(RongIMClient.RCLogInfoListener listener)
Sets the Log output listener. static void
setReadReceiptListener(RongIMClient.ReadReceiptListener listener)
Sets the message receipt listener. static void
setServerInfo(String naviServer, String fileServer)
Sets the navigation server and media server addresses for private deployment. static void
setStatisticDomain(String domain)
Configures the data upload URL (optional). static void
setOnRecallMessageListener(RongIMClient.OnRecallMessageListener listener)
Sets the message recall listener static void
setChatRoomActionListener(RongIMClient.ChatRoomActionListener listener)
Sets the chatroom operation listener. abstract RongIMClient.ConnectionStatusListener.ConnectionStatus
getCurrentConnectionStatus()
Retrieves the current connection status of the IM service. abstract Activity
getTopForegroundActivity()
Retrieves the topmost Activity in the foreground. abstract void
logout()
Disconnects from the RCserver and stops receiving remote push notifications. abstract void
disconnect()
Disconnects from the RCserver while still receiving remote notifications. abstract void
disconnect(boolean isReceivePush)
Disconnects from the RCserver and determines whether to continue receiving remote notifications based on the parameter. abstract void
getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback)
Retrieves the local conversation list of the current user. abstract void
getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieves the local conversation list of the current user based on the conversation type. abstract void
getTopConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieves the list of pinned conversations based on the conversation type. abstract void
getConversationListByPage(RongIMClient.ResultCallback<List<Conversation>> callback, long timeStamp, int count, Array<ConversationType> conversationTypes)
Paginates to get the conversation list. abstract void
getBlockedConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieve the list of conversations with Do Not Disturb enabled. abstract void
getConversation(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Conversation> callback)
Retrieves information of a single conversation. abstract void
updateConversationInfo(ConversationType conversationType, String targetId, String title, String portrait, RongIMClient.ResultCallback callback)
Updates conversation information. abstract void
removeConversation(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Remove a conversation from the conversation list. abstract void
setConversationToTop(ConversationType conversationType, String id, boolean isTop, RongIMClient.ResultCallback<Boolean> callback)
Sets the pinned status of a conversation. abstract void
setConversationToTop(ConversationType conversationType, String id, boolean isTop, boolean needCreate, RongIMClient.ResultCallback<Boolean> callback)
Sets the pinned status of a conversation. abstract void
getTotalUnreadCount(RongIMClient.ResultCallback<Integer> callback)
Retrieves the total count of unread messages across all conversations. abstract void
getTotalUnreadCount(RongIMClient.ResultCallback<Integer> callback, Array<Conversation> conversations)
Retrieves the total count of unread messages for all specified conversations. abstract void
getUnreadCount(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Integer> callback)
Retrieves the count of unread messages for the specified conversation. abstract void
getUnreadCount(RongIMClient.ResultCallback<Integer> callback, Array<ConversationType> conversationTypes)
Retrieves the total count of unread messages for the specified conversation types. abstract void
getUnreadCount(Array<ConversationType> conversationTypes, boolean containBlocked, RongIMClient.ResultCallback<Integer> callback)
Retrieves the total count of unread messages for specified conversation types. abstract void
getUnreadCount(Array<ConversationType> conversationTypes, RongIMClient.ResultCallback<Integer> callback)
Get the total unread message count for specified conversation types. abstract void
getMessageCount(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Integer> callback)
Retrieves the total number of messages in a specified conversation. abstract void
getLatestMessages(ConversationType conversationType, String targetId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieve the latest messages of a specified conversation. abstract List<Message>
getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count)
Retrieves a list of messages that meet the specified criteria in the conversation. abstract List<Message>
getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count)
Retrieves a list of messages in the conversation that meet the specified criteria. abstract void
getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria. abstract void
getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int baseMessageId, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria. abstract void
getHistoryMessages(ConversationType conversationType, String targetId, List<String> objectNames, long timestamp, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria. abstract void
getRemoteHistoryMessages(ConversationType conversationType, String targetId, long dateTime, int count, RongIMClient.ResultCallback<List<Message>> callback)
Fetches historical messages before a specified time from the server. abstract void
getRemoteHistoryMessages(ConversationType conversationType, String targetId, RemoteHistoryMsgOption remoteHistoryMsgOption, RongIMClient.ResultCallback<List<Message>> callback)
Fetches remote historical messages for a specified conversation. abstract void
cleanRemoteHistoryMessages(ConversationType conversationType, String targetId, long recordTime, RongIMClient.OperationCallback callback)
Clears historical messages stored on the server. abstract void
cleanHistoryMessages(ConversationType conversationType, String targetId, long recordTime, boolean cleanRemote, RongIMClient.OperationCallback callback)
Deletes messages before the specified timestamp, with the option to delete messages on the server as well. abstract void
getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves the latest message entities of a specified type, before a specified message, and within a specified count in a conversation. abstract void
deleteMessages(Array<int> messageIds, RongIMClient.ResultCallback<Boolean> callback)
Deletes messages. abstract void
deleteMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes all messages in a specific conversation. abstract void
deleteRemoteMessages(ConversationType conversationType, String targetId, Array<Message> messages, RongIMClient.OperationCallback callback)
Batch deletes specified remote messages in a conversation (also deletes corresponding local messages). abstract void
clearMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes all messages in a specific conversation. abstract void
clearMessagesUnreadStatus(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Clears the unread message count for a specific conversation. abstract void
setMessageExtra(int messageId, String value, RongIMClient.ResultCallback<Boolean> callback)
Sets additional information for a local message. abstract void
setMessageReceivedStatus(int messageId, ReceivedStatus receivedStatus, RongIMClient.ResultCallback<Boolean> callback)
Sets the message received status. abstract void
setMessageSentStatus(Message message, RongIMClient.ResultCallback<Boolean> callback)
Sets the message sending status. abstract void
getTextMessageDraft(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<String> callback)
Retrieves draft information from the conversation. abstract void
saveTextMessageDraft(ConversationType conversationType, String targetId, String content, RongIMClient.ResultCallback<Boolean> callback)
Saves the draft information of a conversation. abstract void
clearTextMessageDraft(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes the draft information in the specified conversation. abstract void
getMessage(int messageId, RongIMClient.ResultCallback<Message> callback)
Retrieves the message body based on the message ID (unique database index value). abstract void
insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation. abstract void
insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, long sentTime, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set to sent. abstract void
insertIncomingMessage(ConversationType type, String targetId, String senderUserId, ReceivedStatus receivedStatus, MessageContent content, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set as received. abstract void
insertIncomingMessage(ConversationType type, String targetId, String senderUserId, ReceivedStatus receivedStatus, MessageContent content, long sentTime, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set as received. abstract void
sendLocationMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMessageCallback sendMessageCallback)
Sends a location message. abstract void
sendMessage(ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a message based on the conversation type. abstract void
sendMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a message. abstract void
sendMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMessageCallback callback)
Sends a message. abstract void
sendDirectionalMessage(ConversationType type, String targetId, MessageContent content, Array<String> userIds, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a targeted message. abstract void
sendImageMessage(ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, RongIMClient.SendImageMessageCallback callback)
Sends an image message. abstract void
sendImageMessage(Message message, String pushContent, String pushData, RongIMClient.SendImageMessageCallback callback)
Sends an image message. abstract void
sendImageMessage(Message message, String pushContent, String pushData, RongIMClient.SendImageMessageWithUploadListenerCallback callback)
Send an image message. abstract void
downloadMedia(ConversationType conversationType, String targetId, RongIMClient.MediaType mediaType, String imageUrl, RongIMClient.DownloadMediaCallback callback)
Downloads a multimedia file. abstract void
downloadMediaMessage(Message message, IRongCallback.IDownloadMediaMessageCallback callback)
Download multimedia files. abstract void
downloadMediaFile(String fileUniqueId, String fileUrl, String fileName, String path, IRongCallback.IDownloadMediaFileCallback callback)
Download a file. abstract void
cancelSendMediaMessage(Message message, RongIMClient.OperationCallback callback)
Cancels sending a multimedia file. abstract void
cancelDownloadMediaMessage(Message message, RongIMClient.OperationCallback callback)
Cancels the download of a multimedia message. abstract void
pauseDownloadMediaMessage(Message message, RongIMClient.OperationCallback callback)
Pauses the download of a multimedia message. abstract void
pauseDownloadMediaFile(String fileUniqueId, RongIMClient.OperationCallback callback)
Pauses the download of a multimedia file. abstract void
getConversationNotificationStatus(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<ConversationNotificationStatus> callback)
Retrieves the message reminder status of a conversation. abstract void
setConversationNotificationStatus(ConversationType conversationType, String targetId, ConversationNotificationStatus notificationStatus, RongIMClient.ResultCallback<ConversationNotificationStatus> callback)
Sets the message notification status for a conversation. abstract String
getCurrentUserId()
Retrieves information about the currently connected user. abstract long
getDeltaTime()
Retrieves the time difference between local time and server time. abstract void
clearConversations(RongIMClient.ResultCallback callback, Array<ConversationType> conversationTypes)
Clears all conversations and their messages for the specified conversation types. abstract void
addToBlacklist(String userId, RongIMClient.OperationCallback callback)
Add a user to the blocklist. abstract void
)>getPrivateDownloadToken(String fileName, ResultCallback<String> callback)
This interface is only applicable for private cloud SDK calls and is no longer supported in the current version. abstract void
removeFromBlacklist(String userId, RongIMClient.OperationCallback callback)
Removes a user from the blocklist. abstract void
getBlacklistStatus(String userId, RongIMClient.ResultCallback<RongIMClient.BlacklistStatus> callback)
Checks whether a user is in the blocklist. abstract void
getBlacklist(RongIMClient.GetBlacklistCallback callback)
Retrieves the current user's blocklist. abstract void
setNotificationQuietHours(String startTime, int spanMinutes, RongIMClient.OperationCallback callback)
Sets the Do Not Disturb time for message notifications. abstract void
removeNotificationQuietHours(RongIMClient.OperationCallback callback)
Remove the Do Not Disturb period for message notifications. abstract void
clearMessagesUnreadStatus(ConversationType conversationType, String targetId, long timestamp, RongIMClient.OperationCallback callback)
Clears the unread message count for a specific conversation. abstract long
getSendTimeByMessageId(int messageId)
Retrieves the sending time of a message based on its message ID. abstract void
getNotificationQuietHours(RongIMClient.GetNotificationQuietHoursCallback callback)
Get the quiet hours for message notifications. abstract void
getMessageByUid(String uid, RongIMClient.ResultCallback<Message> callback)
Retrieve the message entity by its globally unique ID. abstract void
switchAppKey(String appKey)
Switch appKey. abstract Collection<TypingStatus>
getTypingUserListFromConversation(ConversationType conversationType, String targetId)
Retrieves the list of users currently typing in the conversation. abstract void
sendTypingStatus(ConversationType conversationType, String targetId, String typingContentType)
Sends a typing status to the conversation. abstract void
sendReadReceiptMessage(ConversationType conversationType, String targetId, long timestamp)
Sends a read receipt for messages in a specific conversation For IMLib, you can register a listener using setReadReceiptListener; for IMKit, directly set rc_read_receipt
to true in rc_config.xml.abstract void
sendReadReceiptMessage(ConversationType conversationType, String targetId, long timestamp, IRongCallback.ISendMessageCallback callback)
Send read receipts for messages in a conversation. abstract void
setOnReceiveDestructionMessageListener(RongIMClient.OnReceiveDestructionMessageListener listener)
Sets the listener for receiving auto-destroy messages. abstract void
recallMessage(Message message, String pushContent, RongIMClient.ResultCallback<RecallNotificationMessage> callback)
Recall a message abstract void
getUnreadMentionedMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves unread @ messages in the conversation. abstract void
sendMediaMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallback callback)
Sends a multimedia message. abstract void
sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMediaMessageCallback callback)
Sends a multimedia message. abstract void
sendDirectionalMediaMessage(Message message, Array<String> userIds, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallback callback)
Sends a targeted multimedia message. abstract void
sendMediaMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallbackWithUploader callback)
To send multimedia messages, you can use this method to upload multimedia files to your own server. abstract void
sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMediaMessageCallbackWithUploader callback)
Sends a multimedia message, allowing you to upload multimedia files to your own server. abstract void
sendReadReceiptRequest(Message message, RongIMClient.OperationCallback callback)
Initiates a read receipt request for a message (only supported for groups and discussion groups). abstract void
sendReadReceiptResponse(ConversationType type, String targetId, List<Message> messageList, RongIMClient.OperationCallback callback)
Send Read Receipt (Supported for Groups and Discussion Groups Only) abstract void
syncConversationReadStatus(ConversationType type, String targetId, long timestamp, RongIMClient.OperationCallback callback)
Synchronizes the read status of a conversation. abstract void
setSyncConversationReadStatusListener(RongIMClient.SyncConversationReadStatusListener listener)
Sets the listener for multi-device synchronization of conversation read status. abstract void
searchConversations(String keyword, Array<ConversationType> conversationTypes, Array<String> objectNames, RongIMClient.ResultCallback<List<SearchConversationResult>> resultCallback)
Searches for conversations based on keywords. abstract void
searchMessages(ConversationType conversationType, String targetId, String keyword, int count, long beginTime, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages in a specified conversation based on a keyword. abstract void
searchMessagesByUser(ConversationType conversationType, String targetId, String userId, int count, long beginTime, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages in a specified conversation based on the user ID. abstract void
getHistoryMessages(ConversationType conversationType, String targetId, long sentTime, int before, int after, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages before and after the specified message in a conversation. abstract void
getVendorToken(RongIMClient.ResultCallback<String> resultCallback)
Retrieves the authentication information of the logged-in user. abstract void
setPushLanguage(RongIMClient.PushLanguage language, RongIMClient.OperationCallback callback)
Sets the language for remote push notifications. abstract void
setPushLanguageCode(String language, RongIMClient.OperationCallback callback)
Sets the natural language for push notification content. abstract void
setPushContentShowStatus(boolean showStatus, RongIMClient.OperationCallback callback)
Sets whether to display the details of remote push notifications. abstract void
setPushReceiveStatus(boolean receiveStatus, RongIMClient.OperationCallback callback)
Sets whether to receive remote push notifications. abstract void
getPushLanguage(RongIMClient.ResultCallback<RongIMClient.PushLanguage> callback)
Retrieves the remote push notification language settings. abstract void
getPushContentShowStatus(RongIMClient.ResultCallback<Boolean> callback)
Retrieves the setting for displaying detailed content of remote push notifications. abstract void
getPushReceiveStatus(RongIMClient.ResultCallback<Boolean> callback)
Retrieves the setting for receiving remote push notifications. abstract void
getOfflineMessageDuration(RongIMClient.ResultCallback<String> callback)
Retrieves the offline message storage duration (in days). abstract void
setOfflineMessageDuration(int duration, RongIMClient.ResultCallback<Long> callback)
Sets the storage duration of offline messages on the server (in days). abstract void
setAppVer(String appVer)
Sets the version information of the user application integrated with the RongCloud SDK. abstract void
supportResumeBrokenTransfer(String url, RongIMClient.ResultCallback<Boolean> callback)
Determines whether resumable upload is supported. abstract void
getTheFirstUnreadMessage(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Message> callback)
Get the first unread message. abstract boolean
isFileDownloading(int messageId)
Determines whether the file is currently being downloaded. abstract boolean
isFileDownloading(String uid)
Determine whether the file is currently being downloaded. abstract void
setMessageReadTime(long messageId, long timestamp, RongIMClient.OperationCallback callback)
Sets the read timestamp for a message. abstract int
getVideoLimitTime()
Gets the maximum allowed duration for sending video files. abstract int
getGIFLimitSize()
Gets the maximum allowed size for sending GIF images. abstract void
setReconnectKickEnable(boolean enable)
Specifies whether to kick out the reconnecting device during reconnection. abstract void
appOnStart()
Notifies the SDK that the application has returned to the foreground. abstract void
setRLogLevel(int pLevel)
Sets the log level for writing business logs to files. abstract void
setRLogFileMaxSize(long pSize)
Sets the size of the business log file, with a default of 1M. abstract void
setUploadCallback(UploadCallback pCallback)
Sets the callback for uploading RLog logs to the server abstract void
uploadRLog()
Upload RLog logs Invoke this method after successfully calling connect abstract void
beginDestructMessage(Message message, RongIMClient.DestructCountDownTimerListener pListener)
Starts burning the message. abstract void
stopDestructMessage(Message message)
Cancel the burn-after-reading message. abstract void
cancelSDKHeartBeat()
Cancel the wakelock heartbeat. abstract void
sendPing()
OEM implements heartbeat alignment, sending Ping interface 1. abstract void
setConversationStatusListener(RongIMClient.ConversationStatusListener listener)
Sets up multi-device synchronization monitoring for conversation status (pinned and Do Not Disturb) abstract void
setMessageExpansionListener(RongIMClient.MessageExpansionListener listener)
Sets the message extension listener abstract void
updateMessageExpansion(Map<String, String> expansion, String messageUId, RongIMClient.OperationCallback callback)
Update message extension information Each message can carry a maximum of 300 key-value pairs of extension information. abstract void
removeMessageExpansion(List<String> keyArray, String messageUId, RongIMClient.OperationCallback callback)
Deletes specific key-value pairs from message extension information. abstract void
getChatroomHistoryMessages(String targetId, long recordTime, int count, RongIMClient.TimestampOrder order, IRongCallback.IChatRoomHistoryMessageCallback callback)
Retrieves chatroom historical messages. abstract void
getChatRoomInfo(String chatRoomId, int defMemberCount, ChatRoomMemberOrder order, RongIMClient.ResultCallback<ChatRoomInfo> callback)
Retrieves chatroom information (including partial member information and the total number of members in the chatroom). abstract void
joinChatRoom(String chatRoomId, int defMessageCount, RongIMClient.OperationCallback callback)
Joins a chatroom. abstract void
joinExistChatRoom(String chatRoomId, int defMessageCount, RongIMClient.OperationCallback callback)
Join an existing chatroom. abstract void
bindChatRoomWithRTCRoom(String chatRoomId, String RTCRoomId, RongIMClient.OperationCallback callback)
Bind chatRoom and RTCRoom. abstract void
quitChatRoom(String chatRoomId, RongIMClient.OperationCallback callback)
Exits the chatroom. abstract void
setChatRoomEntry(String chatRoomId, String key, String value, boolean sendNotification, boolean autoDelete, String notificationExtra, RongIMClient.OperationCallback callback)
Sets custom attributes for a chatroom. abstract void
forceSetChatRoomEntry(String chatRoomId, String key, String value, boolean sendNotification, boolean autoDelete, String notificationExtra, RongIMClient.OperationCallback callback)
Forcefully sets custom attributes for a chatroom. abstract void
getChatRoomEntry(String chatRoomId, String key, RongIMClient.ResultCallback<Map<String, String>> callback)
Retrieves a single attribute of the chatroom. abstract void
getAllChatRoomEntries(String chatRoomId, RongIMClient.ResultCallback<Map<String, String>> callback)
Retrieves all attributes of a chatroom. abstract void
removeChatRoomEntry(String chatRoomId, String key, Boolean sendNotification, String notificationExtra, RongIMClient.OperationCallback callback)
Deletes chatroom custom attributes. abstract void
forceRemoveChatRoomEntry(String chatRoomId, String key, Boolean sendNotification, String notificationExtra, RongIMClient.OperationCallback callback)
Forces the deletion of chatroom custom attributes. abstract void
setKVStatusListener(RongIMClient.KVStatusListener listener)
Sets up a listener for chatroom KV status changes. abstract void
searchPublicService(RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Search for public services. abstract void
searchPublicServiceByType(PublicServiceType publicServiceType, RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Search for public services by public service type. abstract void
subscribePublicService(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback)
Subscribe to an Official Account. abstract void
unsubscribePublicService(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback)
Unsubscribes from an official account. abstract void
getPublicServiceProfile(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.ResultCallback<PublicServiceProfile> callback)
Retrieves information about a public service. abstract void
getPublicServiceList(RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Retrieves the list of followed official accounts. abstract void
getDiscussion(String discussionId, RongIMClient.ResultCallback<Discussion> callback)
Retrieve information about a discussion group. abstract void
setDiscussionName(String discussionId, String name, RongIMClient.OperationCallback callback)
Sets the name of a discussion group. abstract void
createDiscussion(String name, List<String> userIdList, RongIMClient.CreateDiscussionCallback callback)
Creates a discussion group. abstract void
addMemberToDiscussion(String discussionId, List<String> userIdList, RongIMClient.OperationCallback callback)
Adds users to a discussion group. abstract void
removeMemberFromDiscussion(String discussionId, String userId, RongIMClient.OperationCallback callback)
Removes a user from a discussion group. abstract void
quitDiscussion(String discussionId, RongIMClient.OperationCallback callback)
Exits the current discussion group. abstract void
setDiscussionInviteStatus(String discussionId, RongIMClient.DiscussionInviteStatus status, RongIMClient.OperationCallback callback)
Sets the invitation permissions for discussion group members. abstract RealTimeLocationErrorCode
getRealTimeLocation(ConversationType conversationType, String targetId)
Retrieves an instance of RealTimeLocation. abstract RealTimeLocationErrorCode
startRealTimeLocation(ConversationType conversationType, String targetId)
Initiates location sharing. abstract RealTimeLocationErrorCode
joinRealTimeLocation(ConversationType conversationType, String targetId)
Join location sharing. abstract void
quitRealTimeLocation(ConversationType conversationType, String targetId)
Exits location sharing. abstract List<String>
getRealTimeLocationParticipants(ConversationType conversationType, String targetId)
Retrieves all members participating in location sharing. abstract RealTimeLocationStatus
getRealTimeLocationCurrentState(ConversationType conversationType, String targetId)
Retrieves the status of location sharing. abstract void
addRealTimeLocationListener(ConversationType conversationType, String targetId, RongIMClient.RealTimeLocationListener listener)
Adds a location sharing listener. abstract void
removeRealTimeLocationObserver(ConversationType conversationType, String targetId)
Removes the location sharing listener. abstract void
updateRealTimeLocationStatus(ConversationType conversationType, String targetId, double latitude, double longitude, RealTimeLocationType realTimeLocationType)
Updates location sharing information. abstract void
startCustomService(String kefuId, ICustomServiceListener listener, CSCustomServiceInfo customServiceInfo)
Starts the customer service. abstract void
selectCustomServiceGroup(String kefuId, String groupId)
Send a message to transfer to human customer support abstract void
switchToHumanMode(String kefuId)
Switch to manual customer service mode. abstract void
evaluateCustomService(String kefuId, boolean isRobotResolved, String knowledgeId)
Evaluates the customer service bot for separate evaluation of human and bot interactions. abstract void
evaluateCustomService(String kefuId, int source, String suggest, String dialogId)
Evaluates the human customer service agent, used for separate evaluation of human and bot agents. abstract void
evaluateCustomService(String kefuId, int source, CSEvaSolveStatus resolvestatus, String tagText, String suggest, String dialogId, String extra)
Evaluates the customer service bot, allowing separate evaluations for human and bot interactions. abstract void
evaluateCustomService(String kefuId, int source, CSEvaSolveStatus solveStatus, String suggest, String dialogId)
Evaluation for chatbot customer service, used for unified evaluation of both human and chatbot interactions. abstract void
leaveMessageCustomService(String kefuId, Map<String, String> contentMap, RongIMClient.OperationCallback operationCallback)
Customer service message. abstract void
stopCustomService(String kefuId)
Exits the customer support service. abstract void
setCustomServiceHumanEvaluateListener(OnHumanEvaluateListener listener)
Sets up the manual evaluation listener. abstract void
batchInsertMessage(List<Message> messages, RongIMClient.ResultCallback<Boolean> callback)
Batch inserts received messages (these messages are only inserted into the local database and are not actually sent to the server or the other party). abstract void
getDownloadInfo(String tag, RongIMClient.ResultCallback<DownloadInfo> callback)
Retrieves media file download information. abstract void
setMessageBlockListener(MessageBlockListener listener)
Sets the listener for intercepted messages containing sensitive words. abstract boolean
setProxy(RCIMProxy proxy)
abstract RCIMProxy
getCurrentProxy()
abstract void
testProxy(RCIMProxy proxy, String testHost, RongIMClient.Callback callback)
-
-
Method Detail
-
getInstance
static RongIMClient getInstance()
Obtains an instance of the IMLib interface class. This method must be called after initializing the SDK with the `init` method; otherwise, it returns NULL.
- Returns:
An instance of the IMLib interface class.
-
init
static void init(Application application, String appKey)
Initializes the RCSDK. This should be called only once globally throughout the application.
This method must be called in the main process. It is recommended to call it in the Application inherited class.
- Parameters:
application
- The Application class object.appKey
- The App Key obtained after creating an application on the RCDeveloper Platform.
-
init
static void init(Context context)
Initializes the SDK. This should be called only once globally in the application, preferably in the Application inherited class.
- Parameters:
context
- The Context of the Application class.
-
init
static void init(Context context, String appKey)
Initializes the SDK. This should be called only once globally in the application. It is recommended to call this in the Application subclass.
- Parameters:
context
- The Context of the Application class.appKey
- The App Key obtained after creating an application on the RCDeveloper Platform.
-
init
static void init(Context context, String appKey, boolean enablePush)
Initializes the SDK. This should be called only once globally in the application. It is recommended to call this in the Application subclass.
- Parameters:
context
- The Context of the Application class.appKey
- The App Key obtained after creating an application on the RCdeveloper platform.enablePush
- Whether to enable push notification.
-
init
static void init(Context context, String appKey, boolean enablePush, Boolean isMainProcess)
Initializes the SDK. This should be called only once globally throughout the application. It is recommended to call this in the Application subclass.
- Parameters:
context
- The Context of the Application class.appKey
- The App Key obtained after creating an application on the RCdeveloper platform.enablePush
- Whether to enable push notifications.isMainProcess
- Whether it is the main process.
-
connect
static RongIMClient connect(String token, RongIMClient.ConnectCallback connectCallback)
Connects to the RCserver. This method should be called only once globally in the entire application and must be invoked after init.
When this interface returns a non-business error code, the SDK will initiate a reconnection mechanism. If the connection still fails, it will attempt to reconnect when the device's network status changes.If you are using IMKit, please use the method of the same name in RongIM to establish a connection with the RCserver instead of using this method.
When this interface is called, the SDK will attempt to reconnect after a connection failure, resulting in one of the following two scenarios: First, the connection is successful, and onSuccess(userId) is called back. Second, an error that the SDK cannot handle occurs, and onError(errorCode) is called back (e.g., invalid token), and no further reconnection attempts are made.
If you do not want to keep reconnecting, you can use the connect(String, int, ConnectCallback) interface and set the connection timeout time limit.
- Parameters:
token
- The user authentication token (Token) obtained from the server.connectCallback
- The extended connection callback class, which adds a callback for opening the database (OnDatabaseOpened(DatabaseOpenStatus)).- Returns:
An instance of the RongIMClient, the core class of the IM client.
-
connect
static RongIMClient connect(String token, int timeLimit, RongIMClient.ConnectCallback connectCallback)
Connects to the RCserver. This method should be called only once globally within the application and must be invoked after init.
When this interface returns a non-business error code, the SDK will initiate a reconnection mechanism. If the connection still fails, it will attempt to reconnect when the device's network status changes.If you are using IMKit, please use the method of the same name in RongIM to establish a connection with the RCserver, instead of using this method.
- Parameters:
token
- The user authentication token (Token) obtained from the server.timeLimit
- The connection timeout duration in seconds.connectCallback
- The extended connection callback class, which includes a callback for database opening (OnDatabaseOpened(DatabaseOpenStatus)).- Returns:
An instance of RongIMClient, the core class of the IM client.
-
getVersion
static String getVersion()
-
setConnectionStatusListener
static void setConnectionStatusListener(RongIMClient.ConnectionStatusListener listener)
Sets a listener for connection status changes.
When the callback status is TOKEN_INCORRECT, you need to obtain the correct token and actively call connect. If using IMKit, use the method of the same name in RongIM:
setConnectionStatusListener
. removeNotificationQuietHours- Parameters:
listener
- The listener for connection status changes.
-
setOnReceiveMessageListener
@Deprecated() static void setOnReceiveMessageListener(OnReceiveMessageListener listener)
Sets the listener for receiving message events. Note: It is recommended to set a global listener for the application lifecycle.
- Parameters:
listener
- The listener for receiving messages.
-
addOnReceiveMessageListener
static boolean addOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Adds a listener for the message received event. Note: It is recommended to set a global listener for the application lifecycle.
- Parameters:
listener
- The listener for receiving messages.- Returns:
Indicates whether the addition was successful.
-
removeOnReceiveMessageListener
static boolean removeOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Removes the listener for the message received event.
- Parameters:
listener
- The listener for receiving messages.- Returns:
Indicates whether the removal was successful.
-
registerMessageType
@Deprecated() static void registerMessageType(Class<out MessageContent> messageContentClass)
Register custom message types
Call this method after initialization but before connecting to register custom messages.
- Parameters:
messageContentClass
- The class of the custom message, which must inherit from .
-
registerMessageType
static void registerMessageType(List<Class<out MessageContent>> messageContentClassList)
Batch register custom message types
Call this method to register custom messages after initialization and before connection.
- Parameters:
messageContentClassList
- List of custom message classes.
-
setTypingStatusListener
static void setTypingStatusListener(RongIMClient.TypingStatusListener listener)
Sets the typing status listener.
When the typing status changes, the callback onTypingStatusChanged is triggered. For one-to-one chats, the listener is triggered once when the other party is typing, and once again when the other party stops typing, but the callback will return an empty list of typing users.
- Parameters:
listener
- The typing status listener
-
setRCLogInfoListener
static void setRCLogInfoListener(RongIMClient.RCLogInfoListener listener)
Sets the Log output listener.
Note: Must be called before connect!
- Parameters:
listener
- Log output listener
-
setReadReceiptListener
static void setReadReceiptListener(RongIMClient.ReadReceiptListener listener)
Sets the message receipt listener.
Triggers onReadReceiptReceived when a message receipt is received.
- Parameters:
listener
- The message receipt listener
-
setServerInfo
static void setServerInfo(String naviServer, String fileServer)
Sets the navigation server and media server addresses for private deployment.
Supports setting addresses in the format of http://cn.xxx.com, https://cn.xxx.com, or cn.xxx.com. If the address is set as cn.xxx.com, the SDK will automatically assemble it into the http:// protocol format. Multiple navigation addresses are supported and must be separated by semicolons (;).Note: This method must be used before init!
- Parameters:
naviServer
- The navigation server address for private deployment.fileServer
- The media server address for private deployment, i.e., the upload address for files and images.
-
setStatisticDomain
static void setStatisticDomain(String domain)
Configures the data upload URL (optional).
If this URL is configured, the SDK will upload device-related information to the private cloud node during initialization. This affects the broadcast push functionality in the developer backend. If private cloud customers do not configure this URL, clients will not receive push notifications sent from the backend. Ordinary IM push notifications are not affected. Sets the data upload server URL. It supports URLs in the format of http://cn.xxx.com, https://cn.xxx.com, or cn.xxx.com. If set as cn.xxx.com, the SDK will assemble it into the http:// protocol format.
- Parameters:
domain
- The domain name
-
setOnRecallMessageListener
static void setOnRecallMessageListener(RongIMClient.OnRecallMessageListener listener)
Sets the message recall listener
- Parameters:
listener
- The message recall listener
-
setChatRoomActionListener
static void setChatRoomActionListener(RongIMClient.ChatRoomActionListener listener)
Sets the chatroom operation listener.
Developers can set up a listener to receive callbacks on the status of joining a chatroom.
- Parameters:
listener
- The listener object.
-
getCurrentConnectionStatus
abstract RongIMClient.ConnectionStatusListener.ConnectionStatus getCurrentConnectionStatus()
Retrieves the current connection status of the IM service.
- Returns:
The current connection status ConnectionStatusListener.ConnectionStatus.
-
getTopForegroundActivity
abstract Activity getTopForegroundActivity()
Retrieves the topmost Activity in the foreground.
- Returns:
Returns the topmost Activity if the application is in the foreground; returns NULL if the application is in the background.
-
logout
abstract void logout()
Disconnects from the RCserver and stops receiving remote push notifications.
If you want to continue receiving remote push notifications after disconnecting, you can call disconnect
-
disconnect
abstract void disconnect()
Disconnects from the RCserver while still receiving remote notifications.
To disconnect and stop receiving remote notifications, call logout.Note: Since the SDK automatically reconnects when the app switches between foreground and background or when network issues occur, ensuring connection reliability, you generally do not need to call this method to manually disconnect unless your app logic requires logout.
-
disconnect
abstract void disconnect(boolean isReceivePush)
Disconnects from the RCserver and determines whether to continue receiving remote notifications based on the parameter.
- Parameters:
isReceivePush
-true
Continue receiving remote notifications after disconnection;false
Stop receiving remote notifications after disconnection.
-
getConversationList
abstract void getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback)
Retrieves the local conversation list of the current user. The returned list includes the following types of conversations: one-to-one chat, group, discussion group, and system conversation.
This method reads the conversation list from the local database. The returned conversation list is sorted in chronological order, with pinned conversations appearing at the top. If you need to retrieve other types of conversation lists, you can use getConversationList.This method must be called after the database connection is opened, as indicated by the
OnDatabaseOpened
callback in ConnectCallback.- Parameters:
callback
- The callback for retrieving the conversation list.
-
getConversationList
abstract void getConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieves the local conversation list of the current user based on the conversation type.
- Parameters:
callback
- Callback for retrieving the conversation list.conversationTypes
- The types of conversations to retrieve.
-
getTopConversationList
abstract void getTopConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieves the list of pinned conversations based on the conversation type.
-
getConversationListByPage
abstract void getConversationListByPage(RongIMClient.ResultCallback<List<Conversation>> callback, long timeStamp, int count, Array<ConversationType> conversationTypes)
Paginates to get the conversation list.
- Parameters:
callback
- The callback for retrieving the conversation list.timeStamp
- The timestamp in milliseconds.count
- The number of conversations to retrieve.conversationTypes
- The types of conversations to retrieve.
-
getBlockedConversationList
abstract void getBlockedConversationList(RongIMClient.ResultCallback<List<Conversation>> callback, Array<ConversationType> conversationTypes)
Retrieve the list of conversations with Do Not Disturb enabled.
- Parameters:
callback
- Callback for retrieving Do Not Disturb conversations.conversationTypes
- Conversation types, Conversation.
-
getConversation
abstract void getConversation(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Conversation> callback)
Retrieves information of a single conversation.
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- Callback for retrieving the conversation information.
-
updateConversationInfo
abstract void updateConversationInfo(ConversationType conversationType, String targetId, String title, String portrait, RongIMClient.ResultCallback callback)
Updates conversation information.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversationtitle
- The title of the conversationportrait
- The avatar of the conversationcallback
- The callback
-
removeConversation
abstract void removeConversation(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Remove a conversation from the conversation list.
This method does not delete messages within the conversation. If new messages are received in this conversation, it will reappear in the conversation list and display the most recent history messages.
- Parameters:
conversationType
- The conversation type Conversation.targetId
- The conversation ID.callback
- Callback indicating whether the conversation was successfully removed.
-
setConversationToTop
abstract void setConversationToTop(ConversationType conversationType, String id, boolean isTop, RongIMClient.ResultCallback<Boolean> callback)
Sets the pinned status of a conversation.
Pinning a conversation: Places this conversation at the top of the conversation list (when multiple conversations are pinned, they are sorted by the time they were pinned, with the earliest pinned conversation appearing first). Example: If conversations A, B, and C are pinned in sequence, the order will be A, B, C. If a conversation does not exist when pinned, it will be created in the conversation list; if a pinned conversation is deleted, the pinned status will be automatically removed.
- Parameters:
conversationType
- The type of conversation Conversation.id
- The conversation ID.isTop
- Whether to pin the conversation.callback
- Callback indicating whether the pinning operation was successful.
-
setConversationToTop
abstract void setConversationToTop(ConversationType conversationType, String id, boolean isTop, boolean needCreate, RongIMClient.ResultCallback<Boolean> callback)
Sets the pinned status of a conversation.
If the conversation does not exist, the SDK will automatically create it and pin it.
- Parameters:
conversationType
- The type of conversation Conversation.id
- The conversation ID.isTop
- Whether to pin the conversation.needCreate
- Whether to create the conversation if it does not exist.callback
- Callback to indicate whether the pinning was successful.
-
getTotalUnreadCount
abstract void getTotalUnreadCount(RongIMClient.ResultCallback<Integer> callback)
Retrieves the total count of unread messages across all conversations.
Note: Excludes chatrooms; chatroom messages are not counted.
- Parameters:
callback
- Callback for the unread message count.
-
getTotalUnreadCount
abstract void getTotalUnreadCount(RongIMClient.ResultCallback<Integer> callback, Array<Conversation> conversations)
Retrieves the total count of unread messages for all specified conversations.
Note: Chatrooms are excluded, and chatroom messages are not counted.
- Parameters:
callback
- Callback for retrieving the total count of unread messages for specified conversations.conversations
- Specified conversations.
-
getUnreadCount
abstract void getUnreadCount(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Integer> callback)
Retrieves the count of unread messages for the specified conversation.
Note: Chatrooms are excluded, and messages in chatrooms are not counted.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.callback
- The callback for the count of unread messages.
-
getUnreadCount
abstract void getUnreadCount(RongIMClient.ResultCallback<Integer> callback, Array<ConversationType> conversationTypes)
Retrieves the total count of unread messages for the specified conversation types.
Note: Chatroom messages are not included in the count.
- Parameters:
callback
- Callback for the unread message count.conversationTypes
- Conversation types.
-
getUnreadCount
abstract void getUnreadCount(Array<ConversationType> conversationTypes, boolean containBlocked, RongIMClient.ResultCallback<Integer> callback)
Retrieves the total count of unread messages for specified conversation types.
Note: Chatroom messages are not included in the count.
- Parameters:
conversationTypes
- Array of conversation types Conversation.containBlocked
- Indicates whether to include unread messages from muted conversations.callback
- Callback for the unread message count.
-
getUnreadCount
abstract void getUnreadCount(Array<ConversationType> conversationTypes, RongIMClient.ResultCallback<Integer> callback)
Get the total unread message count for specified conversation types.
Note: Chatroom messages are not included in the count.
- Parameters:
conversationTypes
- Array of conversation types Conversation.callback
- Callback for the unread message count.
-
getMessageCount
abstract void getMessageCount(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Integer> callback)
Retrieves the total number of messages in a specified conversation.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.callback
- Callback for the total number of messages.
-
getLatestMessages
abstract void getLatestMessages(ConversationType conversationType, String targetId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieve the latest messages of a specified conversation.
- Parameters:
conversationType
- Specifies the conversation type .targetId
- Indicates the conversation ID.count
- Specifies the number of messages to retrieve.callback
- Callback for retrieving the latest messages, ordered from newest to oldest.
-
getHistoryMessages
@Deprecated() abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count)
Retrieves a list of messages that meet the specified criteria in the conversation.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.oldestMessageId
- The ID of the last message.count
- The number of messages to retrieve.- Returns:
Historical messages, ordered from newest to oldest.
-
getHistoryMessages
@Deprecated() abstract List<Message> getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count)
Retrieves a list of messages in the conversation that meet the specified criteria.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.objectName
- The message type identifier.oldestMessageId
- The ID of the last message.count
- The number of messages to retrieve.- Returns:
A list of historical messages, sorted from newest to oldest.
-
getHistoryMessages
abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria.
The returned messages do not include the message corresponding to oldestMessageId. If the number of messages in the conversation is less than the value of the count parameter, all messages in the conversation will be returned. For example, if oldestMessageId is 10 and count is 2, the method will return a list of Message objects with messageId 9 and 8.
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.objectName
- The message type identifier.oldestMessageId
- The ID of the last message.count
- The number of messages to retrieve.callback
- The callback for retrieving historical messages, ordered chronologically from newest to oldest.
-
getHistoryMessages
abstract void getHistoryMessages(ConversationType conversationType, String targetId, String objectName, int baseMessageId, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria.
For example, to retrieve the 10 image messages before the message with ID 22, the corresponding parameters would be: getHistoryMessages(conversationType, targetId, RC:ImgMsg, 22, 10, true, resultCallback).
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.objectName
- The message type identifier.baseMessageId
- The starting message ID.count
- The number of messages to retrieve.direction
- The direction of the messages relative to the baseMessageId Using the specified baseMessageId as the starting point, messages earlier than baseMessageId are FRONT, and those later are BEHIND.callback
- The callback for retrieving historical messages, ordered from newest to oldest.
-
getHistoryMessages
abstract void getHistoryMessages(ConversationType conversationType, String targetId, List<String> objectNames, long timestamp, int count, GetMessageDirection direction, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves a list of messages in the conversation that meet the specified criteria.
For example: To get the 10 previous image and text messages before the message with messageId 22, the objectNames should be a List of strings:
objectNames.add(RC:ImgMsg); objectNames.add(RC:TxtMsg);
The corresponding parameters would be: getHistoryMessages(conversationType, targetId, objectNames, 22, 10, true, resultCallback).
- Parameters:
conversationType
- The type of conversation Conversation.targetId
- The ID of the conversation.objectNames
- A List of message type identifiers.timestamp
- The timestamp of the current message.count
- The number of messages to retrieve.direction
- The direction of the messages to retrieve relative to the current message RongCommonDefine.callback
- The callback for retrieving historical messages, ordered from newest to oldest.
-
getRemoteHistoryMessages
abstract void getRemoteHistoryMessages(ConversationType conversationType, String targetId, long dateTime, int count, RongIMClient.ResultCallback<List<Message>> callback)
Fetches historical messages before a specified time from the server.
Unlike getHistoryMessages, this interface pulls data from the RCserver. After pulling messages from the server, the client performs deduplication and returns the deduplicated data. This is typically used to fetch historical messages after switching to a new device. It is recommended to first use getHistoryMessages to fetch historical messages from the local database. If no historical messages are found in the local database, use this interface to fetch server historical messages, passing the timestamp of the earliest message in the local database.Note: 1. This feature requires enabling the historical message cloud storage function in the RCdeveloper console. 2. If the local database already contains the messages to be fetched, this interface will not return any data.
- Parameters:
conversationType
- The conversation type.targetId
- The target conversation ID.dateTime
- Fetches messages starting from this timestamp.count
- The number of messages to fetch,0 < count <= 20
.callback
- The callback for fetching historical messages, ordered from newest to oldest.
-
getRemoteHistoryMessages
abstract void getRemoteHistoryMessages(ConversationType conversationType, String targetId, RemoteHistoryMsgOption remoteHistoryMsgOption, RongIMClient.ResultCallback<List<Message>> callback)
Fetches remote historical messages for a specified conversation.
This feature requires enabling the message cloud storage feature in the RongCloud Developer Console.Note: Chatrooms are not supported!
- Parameters:
conversationType
- The type of conversation.targetId
- The conversation ID.remoteHistoryMsgOption
- Configurable parameters RemoteHistoryMsgOptioncallback
- Callback for retrieving historical messages, ordered from newest to oldest.
-
cleanRemoteHistoryMessages
abstract void cleanRemoteHistoryMessages(ConversationType conversationType, String targetId, long recordTime, RongIMClient.OperationCallback callback)
Clears historical messages stored on the server.
Clears server-side historical messages before the specified timestamp for a specific conversation based on the conversation type and target conversation ID. After successful clearance, only historical messages after this timestamp can be retrieved from the server. Note: The historical message cloud storage feature must be enabled first!
- Parameters:
conversationType
- The type of the conversation.targetId
- The ID of the conversation.recordTime
- The timestamp for clearing messages.callback
- The callback for clearing messages.
-
cleanHistoryMessages
abstract void cleanHistoryMessages(ConversationType conversationType, String targetId, long recordTime, boolean cleanRemote, RongIMClient.OperationCallback callback)
Deletes messages before the specified timestamp, with the option to delete messages on the server as well.
This method can clear historical messages from the server, but the historical message cloud storage feature must be enabled first. It clears messages before the specified timestamp in the local database (or server-side historical messages) based on the conversation type and conversation ID. After successful clearance, only historical messages after the specified timestamp can be retrieved from the local database (or server).
- Parameters:
conversationType
- Specifies the conversation type.targetId
- Specifies the conversation ID.recordTime
- The timestamp before which messages will be deleted.cleanRemote
- Indicates whether to delete messages on the server.callback
- The callback for the message deletion operation.
-
getHistoryMessages
abstract void getHistoryMessages(ConversationType conversationType, String targetId, int oldestMessageId, int count, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves the latest message entities of a specified type, before a specified message, and within a specified count in a conversation.
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.oldestMessageId
- The ID of the last message.count
- The number of messages to retrieve.callback
- The callback for retrieving historical messages, ordered from newest to oldest.
-
deleteMessages
abstract void deleteMessages(Array<int> messageIds, RongIMClient.ResultCallback<Boolean> callback)
Deletes messages.
- Parameters:
messageIds
- An array of message IDs to be deleted.callback
- Callback indicating whether the deletion was successful.
-
deleteMessages
abstract void deleteMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes all messages in a specific conversation.
This interface deletes all messages in the database for the specified conversation and cleans up the database space to reduce storage usage.
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- Callback indicating whether the deletion was successful.
-
deleteRemoteMessages
abstract void deleteRemoteMessages(ConversationType conversationType, String targetId, Array<Message> messages, RongIMClient.OperationCallback callback)
Batch deletes specified remote messages in a conversation (also deletes corresponding local messages).
Each batch operation only supports deleting messages from the same conversation. Ensure all messages in the list belong to the same conversation. A maximum of 100 messages can be deleted in one operation.Note: Chatrooms are not supported!
Versions below 5.6.9 do not support ultra group conversation types. Support for ultra group conversation types starts from version 5.6.9.
- Parameters:
conversationType
- The conversation type.targetId
- The conversation ID.messages
- The array of messages to delete.callback
- Callback indicating whether the deletion was successful.
-
clearMessages
abstract void clearMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes all messages in a specific conversation.
Note: Chatrooms are not supported!
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- Callback indicating whether the operation was successful.
-
clearMessagesUnreadStatus
abstract void clearMessagesUnreadStatus(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Clears the unread message count for a specific conversation.
Note: Not supported for chatrooms!
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- Callback indicating whether the operation was successful.
-
setMessageExtra
abstract void setMessageExtra(int messageId, String value, RongIMClient.ResultCallback<Boolean> callback)
Sets additional information for a local message.
Extends the usage scenarios of the message. After setting, messages with additional information can be retrieved via getHistoryMessages.Note: This can only be used locally and cannot be synchronized with remote users.
- Parameters:
messageId
- The message ID.value
- Additional information, up to 1024 bytes.callback
- Callback indicating whether the setting was successful.
-
setMessageReceivedStatus
abstract void setMessageReceivedStatus(int messageId, ReceivedStatus receivedStatus, RongIMClient.ResultCallback<Boolean> callback)
Sets the message received status.
- Parameters:
messageId
- The message ID.receivedStatus
- The received message status.callback
- Callback indicating whether the setting was successful.
-
setMessageSentStatus
abstract void setMessageSentStatus(Message message, RongIMClient.ResultCallback<Boolean> callback)
Sets the message sending status.
- Parameters:
message
- The message object.callback
- Callback indicating whether the operation was successful.
-
getTextMessageDraft
abstract void getTextMessageDraft(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<String> callback)
Retrieves draft information from the conversation.
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- Callback to retrieve the draft text content.
-
saveTextMessageDraft
abstract void saveTextMessageDraft(ConversationType conversationType, String targetId, String content, RongIMClient.ResultCallback<Boolean> callback)
Saves the draft information of a conversation.
- Parameters:
conversationType
- The type of the conversation.targetId
- The ID of the conversation.content
- The text content of the draft.callback
- Callback indicating whether the save operation was successful.
-
clearTextMessageDraft
abstract void clearTextMessageDraft(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Boolean> callback)
Deletes the draft information in the specified conversation.
- Parameters:
conversationType
- The type of the conversation.targetId
- The ID of the conversation.callback
- Callback indicating whether the deletion was successful.
-
getMessage
abstract void getMessage(int messageId, RongIMClient.ResultCallback<Message> callback)
Retrieves the message body based on the message ID (unique database index value).
- Parameters:
messageId
- The message ID.callback
- The callback.
-
insertOutgoingMessage
abstract void insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation.
This message is only inserted into the local conversation and will not be sent to the server or the other party. The inserted message must be a persisted message, i.e., ISPERSISTED, otherwise, the callback PARAMETER_ERROR will be triggered.
- Parameters:
type
- The type of conversation.targetId
- The ID of the conversation.sentStatus
- The sending status Message.content
- The message content.resultCallback
- The callback to get the message sending entity.
-
insertOutgoingMessage
abstract void insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, long sentTime, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set to sent.
This message is only inserted into the local conversation and will not be actually sent to the server or the recipient. The inserted message must be a persisted message, i.e., ISPERSISTED, otherwise the callback PARAMETER_ERROR will be triggered.
- Parameters:
type
- The type of the conversation.targetId
- The ID of the conversation.sentStatus
- The sending status Message.content
- The content of the message, such as TextMessage, ImageMessage, etc.sentTime
- The sending time of the message getSentTime.resultCallback
- The callback to obtain the message sending entity.
-
insertIncomingMessage
abstract void insertIncomingMessage(ConversationType type, String targetId, String senderUserId, ReceivedStatus receivedStatus, MessageContent content, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set as received.
This message is only inserted into the local conversation and will not be sent to the server or the recipient. The inserted message must be a persisted message, i.e., ISPERSISTED, otherwise the callback PARAMETER_ERROR will be triggered.
- Parameters:
type
- The type of the conversation.targetId
- The ID of the conversation.senderUserId
- The ID of the sender.receivedStatus
- The received status Message.content
- The content of the message, such as TextMessage, ImageMessage, etc.resultCallback
- The callback to obtain the message sending entity.
-
insertIncomingMessage
abstract void insertIncomingMessage(ConversationType type, String targetId, String senderUserId, ReceivedStatus receivedStatus, MessageContent content, long sentTime, RongIMClient.ResultCallback<Message> resultCallback)
Inserts a message into the local conversation with the direction set as received.
This message is only inserted into the local conversation and will not be sent to the server or the other party. The inserted message must be a persisted message, i.e., ISPERSISTED, otherwise, the callback PARAMETER_ERROR will be triggered.
- Parameters:
type
- The type of the conversation.targetId
- The ID of the conversation.senderUserId
- The ID of the sender.receivedStatus
- The received status Message.content
- The content of the message.sentTime
- The sent time of the message getSentTime.resultCallback
- Callback to obtain the message entity.
-
sendLocationMessage
abstract void sendLocationMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMessageCallback sendMessageCallback)
Sends a location message.
Before sending, construct a Message object. The content of the message must be LocationMessage, otherwise it will fail. The thumbnail URL scheme only supports file:// and http://. You can also omit the thumbnail URL by passing NULL.
- Parameters:
message
- The message object.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for the remote push notification.sendMessageCallback
- Callback for sending the message.
-
sendMessage
abstract void sendMessage(ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a message based on the conversation type.
The message status and message body are returned through the methods in .Note: The message sending rate is limited to 5 messages per second.
- Parameters:
type
- The conversation type.targetId
- The conversation ID.content
- The message content, such as TextMessage, ImageMessage.pushContent
- The field displayed in the notification bar when a remote push notification is sent.pushData
- Additional information for remote push notifications.callback
- The callback for sending the message.
-
sendMessage
abstract void sendMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a message.
The status and body of the sent message are returned through the methods in .Note: The message sending rate is limited to 5 messages per second.
- Parameters:
message
- The message body to be sent.pushContent
- This field is displayed in the notification bar when a remote push notification is sent.pushData
- Additional information for the remote push notification.callback
- The callback for sending the message, refer to .
-
sendMessage
abstract void sendMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMessageCallback callback)
Sends a message.
The status and body of the sent message are returned through the methods in .Note: The message sending rate is limited to 5 messages per second.
- Parameters:
message
- The message body to be sent.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for remote push notifications.option
- Additional options for sending messages.callback
- The callback for sending the message, refer to .
-
sendDirectionalMessage
abstract void sendDirectionalMessage(ConversationType type, String targetId, MessageContent content, Array<String> userIds, String pushContent, String pushData, IRongCallback.ISendMessageCallback callback)
Sends a targeted message.
This method is used to send a message to specific users within a group or ultra group, while other users will not receive this message. The message status and body are returned through the methods in IRongCallback.ISendMessageCallback. This method can only send non-multimedia messages. For multimedia messages such as , FileMessage, or other messages inherited from , use sendDirectionalMediaMessage. If you are using IMLib, you can use this method to send targeted messages. If you are using IMKit, please use the method with the same name in RongIM to send targeted messages; otherwise, the UI will not be updated automatically.
Starting from version 5.6.9, ultra group conversation types are supported.
- Parameters:
type
- The conversation type.targetId
- The conversation ID, which could be a group ID or ultra group ID.content
- The message content, such as TextMessage or ImageMessage.userIds
- The list of users in the discussion group or group conversation who will receive this message.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for the remote push notification.callback
- The callback for sending the message, refer to .
-
sendImageMessage
abstract void sendImageMessage(ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, RongIMClient.SendImageMessageCallback callback)
Sends an image message.
If you are using IMLib, you can use this method to send an image message. If you are using IMKit, please use the method with the same name in RongIM to send the image message; otherwise, the UI will not be updated automatically.
- Parameters:
type
- The type of conversation.targetId
- The ID of the conversation.content
- The message content, such as TextMessage, ImageMessage.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for the remote push notification.callback
- The callback for sending the message.
-
sendImageMessage
abstract void sendImageMessage(Message message, String pushContent, String pushData, RongIMClient.SendImageMessageCallback callback)
Sends an image message.
If you are using IMLib, you can use this method to send an image message. If you are using IMKit, please use the method with the same name in RongIM to send an image message; otherwise, the UI will not be automatically updated.
- Parameters:
message
- The message object to be sent.pushContent
- This field will be displayed in the notification bar when a remote push notification is sent.pushData
- Additional information for remote push notifications.callback
- The callback for sending the message.
-
sendImageMessage
abstract void sendImageMessage(Message message, String pushContent, String pushData, RongIMClient.SendImageMessageWithUploadListenerCallback callback)
Send an image message.
This method uploads the image to your own server for sending and updates the image status. When using this method to upload an image, the will be triggered. This callback carries an UploadImageStatusListener object, and the user only needs to call the following methods:update to update the progress success to update the success status and provide the uploaded image URL error to update the failure status
- Parameters:
message
- The message entity to be sent.pushContent
- This field will be displayed in the notification bar when a remote push notification is sent.pushData
- Additional information for remote push notifications.callback
- The callback for sending the message, which carries an object.
-
downloadMedia
abstract void downloadMedia(ConversationType conversationType, String targetId, RongIMClient.MediaType mediaType, String imageUrl, RongIMClient.DownloadMediaCallback callback)
Downloads a multimedia file.
If the file is available in the local cache, it will be retrieved directly from the cache. Otherwise, it will be downloaded from the server.
- Parameters:
conversationType
- The type of conversation.targetId
- The conversation ID.mediaType
- The type of file.imageUrl
- The URL of the file.callback
- The callback for the file download.
-
downloadMediaMessage
abstract void downloadMediaMessage(Message message, IRongCallback.IDownloadMediaMessageCallback callback)
Download multimedia files.
- Parameters:
message
- The media message (FileMessage, SightMessage, GIFMessage, HQVoiceMessage, etc.).callback
- The callback for downloading the file.
-
downloadMediaFile
abstract void downloadMediaFile(String fileUniqueId, String fileUrl, String fileName, String path, IRongCallback.IDownloadMediaFileCallback callback)
Download a file.
Supports resumable downloads. To pause the download, use pauseDownloadMediaFile.
- Parameters:
fileUniqueId
- Unique identifier of the file, corresponding to the first parameter of pauseDownloadMediaFilefileUrl
- URL of the file to downloadfileName
- Name of the filepath
- Directory to save the downloaded file.callback
- Callback for file download
-
cancelSendMediaMessage
abstract void cancelSendMediaMessage(Message message, RongIMClient.OperationCallback callback)
Cancels sending a multimedia file.
- Parameters:
message
- The multimedia file message.callback
- Callback triggered when the multimedia file sending is canceled.
-
cancelDownloadMediaMessage
abstract void cancelDownloadMediaMessage(Message message, RongIMClient.OperationCallback callback)
Cancels the download of a multimedia message.
- Parameters:
message
- The multimedia file message.callback
- Callback triggered when the multimedia file download is canceled.
-
pauseDownloadMediaMessage
abstract void pauseDownloadMediaMessage(Message message, RongIMClient.OperationCallback callback)
Pauses the download of a multimedia message.
- Parameters:
message
- The multimedia file message.callback
- The callback triggered when the download of the multimedia file is paused.
-
pauseDownloadMediaFile
abstract void pauseDownloadMediaFile(String fileUniqueId, RongIMClient.OperationCallback callback)
Pauses the download of a multimedia file.
- Parameters:
fileUniqueId
- The unique identifier of the file.callback
- The callback triggered when the multimedia file download is paused.
-
getConversationNotificationStatus
abstract void getConversationNotificationStatus(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<ConversationNotificationStatus> callback)
Retrieves the message reminder status of a conversation.
Note: Chatrooms are not supported!
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- The callback to retrieve the message reminder status.
-
setConversationNotificationStatus
abstract void setConversationNotificationStatus(ConversationType conversationType, String targetId, ConversationNotificationStatus notificationStatus, RongIMClient.ResultCallback<ConversationNotificationStatus> callback)
Sets the message notification status for a conversation.
Note: Chatrooms are not supported!
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.notificationStatus
- The message notification status to set for the conversation .callback
- The callback for setting the status.
-
getCurrentUserId
abstract String getCurrentUserId()
Retrieves information about the currently connected user.
- Returns:
Information about the currently connected user.
-
getDeltaTime
abstract long getDeltaTime()
Retrieves the time difference between local time and server time.
After a message is successfully sent, the SDK synchronizes time with the server. The time stored in the message database is the server time. Use System.currentTimeMillis() - getDeltaTime() to obtain the current server time.
- Returns:
The difference between local time and server time.
-
clearConversations
abstract void clearConversations(RongIMClient.ResultCallback callback, Array<ConversationType> conversationTypes)
Clears all conversations and their messages for the specified conversation types.
- Parameters:
callback
- Callback indicating whether the operation was successful.conversationTypes
- List of conversation types to be cleared.
-
addToBlacklist
abstract void addToBlacklist(String userId, RongIMClient.OperationCallback callback)
Add a user to the blocklist.
After adding the user to the blocklist, when the user sends a message, they will receive a notification saying Your message has been sent, but was rejected by the recipient. However, you can still send messages to the user.
- Parameters:
userId
- The user ID.callback
- Callback triggered when the user is added to the blocklist.
-
getPrivateDownloadToken
@Deprecated() abstract void )>getPrivateDownloadToken(String fileName, ResultCallback<String> callback)
This interface is only applicable for private cloud SDK calls and is no longer supported in the current version. Private cloud users should use the new interface getMediaUploadAuthorInfo
- Parameters:
fileName
- The name of the filecallback
- Returns the authentication token
-
removeFromBlacklist
abstract void removeFromBlacklist(String userId, RongIMClient.OperationCallback callback)
Removes a user from the blocklist.
- Parameters:
userId
- The user ID.callback
- Callback for blocklist removal.
-
getBlacklistStatus
abstract void getBlacklistStatus(String userId, RongIMClient.ResultCallback<RongIMClient.BlacklistStatus> callback)
Checks whether a user is in the blocklist.
- Parameters:
userId
- The user ID.callback
- Callback to check if the user is in the blocklist.
-
getBlacklist
abstract void getBlacklist(RongIMClient.GetBlacklistCallback callback)
Retrieves the current user's blocklist.
- Parameters:
callback
- Callback for retrieving the blocklist.
-
setNotificationQuietHours
abstract void setNotificationQuietHours(String startTime, int spanMinutes, RongIMClient.OperationCallback callback)
Sets the Do Not Disturb time for message notifications.
- Parameters:
startTime
- The start time in the format HH:MM:SS.spanMinutes
- The duration in minutes from the start time to the end time of Do Not Disturb.callback
- The callback for the Do Not Disturb time setting.
-
removeNotificationQuietHours
abstract void removeNotificationQuietHours(RongIMClient.OperationCallback callback)
Remove the Do Not Disturb period for message notifications.
- Parameters:
callback
- Callback for removing the Do Not Disturb period for message notifications.
-
clearMessagesUnreadStatus
abstract void clearMessagesUnreadStatus(ConversationType conversationType, String targetId, long timestamp, RongIMClient.OperationCallback callback)
Clears the unread message count for a specific conversation.
Note: Chatrooms are not supported!
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.timestamp
- The timestamp of the last message read in this conversation.callback
- Callback indicating whether the operation was successful.
-
getSendTimeByMessageId
abstract long getSendTimeByMessageId(int messageId)
Retrieves the sending time of a message based on its message ID.
- Parameters:
messageId
- The specified message ID.- Returns:
The time when the message was successfully sent.
-
getNotificationQuietHours
abstract void getNotificationQuietHours(RongIMClient.GetNotificationQuietHoursCallback callback)
Get the quiet hours for message notifications.
- Parameters:
callback
- Callback for the quiet hours of message notifications.
-
getMessageByUid
abstract void getMessageByUid(String uid, RongIMClient.ResultCallback<Message> callback)
Retrieve the message entity by its globally unique ID.
- Parameters:
uid
- The globally unique ID (server message unique ID).callback
- The callback for retrieving the message.
-
switchAppKey
abstract void switchAppKey(String appKey)
Switch appKey.
When an application corresponds to multiple environments, i.e., multiple appKeys, call this method to perform a hot switch of the RCSDK. Note: After calling this method, you need to call init and connect again, passing the token corresponding to the new appKey to reinitialize and reconnect.
- Parameters:
appKey
- The other appKey of the application.
-
getTypingUserListFromConversation
abstract Collection<TypingStatus> getTypingUserListFromConversation(ConversationType conversationType, String targetId)
Retrieves the list of users currently typing in the conversation.
- Parameters:
conversationType
- The type of the conversation.targetId
- The ID of the conversation.- Returns:
The list of users currently typing in the conversation.
-
sendTypingStatus
abstract void sendTypingStatus(ConversationType conversationType, String targetId, String typingContentType)
Sends a typing status to the conversation. Currently, only one-to-one chat is supported.
- Parameters:
conversationType
- The type of the conversation.targetId
- The ID of the conversation.typingContentType
- The type name of the message being typed.
-
sendReadReceiptMessage
abstract void sendReadReceiptMessage(ConversationType conversationType, String targetId, long timestamp)
Sends a read receipt for messages in a specific conversation
For IMLib, you can register a listener using setReadReceiptListener; for IMKit, directly set
rc_read_receipt
to true in rc_config.xml.- Parameters:
conversationType
- The type of conversation (only applicable to PRIVATE and ENCRYPTED types)targetId
- The conversation IDtimestamp
- The timestamp of the last read message in the conversation getSentTime
-
sendReadReceiptMessage
abstract void sendReadReceiptMessage(ConversationType conversationType, String targetId, long timestamp, IRongCallback.ISendMessageCallback callback)
Send read receipts for messages in a conversation.
With IMLib, you can register a listener using setReadReceiptListener; with IMKit, simply set
rc_read_receipt
to true in rc_config.xml.- Parameters:
conversationType
- Conversation type (only applicable to PRIVATE and ENCRYPTED types)targetId
- Conversation IDtimestamp
- Timestamp of the last read message in the conversation getSentTimecallback
- Callback for sending read receipt messages
-
setOnReceiveDestructionMessageListener
abstract void setOnReceiveDestructionMessageListener(RongIMClient.OnReceiveDestructionMessageListener listener)
Sets the listener for receiving auto-destroy messages.
- Parameters:
listener
- The listener for receiving auto-destroy messages.
-
recallMessage
abstract void recallMessage(Message message, String pushContent, RongIMClient.ResultCallback<RecallNotificationMessage> callback)
Recall a message
- Parameters:
message
- The message to be recalledpushContent
- When sending a push notification, this field will be displayed in the notification bar.callback
- The RecallNotificationMessage will be returned in the onSuccess callback.
-
getUnreadMentionedMessages
abstract void getUnreadMentionedMessages(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<List<Message>> callback)
Retrieves unread @ messages in the conversation.
- Parameters:
conversationType
- Specifies the conversation type.targetId
- Represents the conversation ID.callback
- Callback for retrieving unread @ messages.
-
sendMediaMessage
abstract void sendMediaMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallback callback)
Sends a multimedia message.
Before sending, construct a Message object where the content must be a multimedia message. For example: ImageMessage, FileMessage, or any other message that inherits from MediaMessageContent.
- Parameters:
message
- The message entity to be sent.pushContent
- This field will be displayed in the notification bar when a remote push notification is sent.pushData
- Additional information for remote push notifications.callback
- The callback for sending the message SendMediaMessageCallback.
-
sendMediaMessage
abstract void sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMediaMessageCallback callback)
Sends a multimedia message.
Construct a Message entity before sending. The content in the message entity must be a multimedia message. For example: ImageMessage, FileMessage, or other messages that inherit from MediaMessageContent.
- Parameters:
message
- The message entity to be sent.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for remote push notifications.option
- Additional options for sending the message.callback
- The callback for sending the message SendMediaMessageCallback.- Since:
5.4.4
-
sendDirectionalMediaMessage
abstract void sendDirectionalMediaMessage(Message message, Array<String> userIds, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallback callback)
Sends a targeted multimedia message.
Sends a message to specific users in a conversation; other users in the conversation will not receive the message. Before sending, construct a Message entity, where the content must be a multimedia message. For example: ImageMessage, FileMessage, or any other message that inherits from MediaMessageContent.
Starting from version 5.6.9, ultra group conversation types are supported.
- Parameters:
message
- The message entity to be sent.userIds
- An array of targeted recipient IDs.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for the remote push notification.callback
- The callback for sending the message SendMediaMessageCallback.
-
sendMediaMessage
abstract void sendMediaMessage(Message message, String pushContent, String pushData, IRongCallback.ISendMediaMessageCallbackWithUploader callback)
To send multimedia messages, you can use this method to upload multimedia files to your own server.
When uploading a multimedia file, the callback onAttached will be triggered. This callback carries the object. Users only need to call the following methods within this object: update to update the progress success to update the success status and provide the file URL after successful upload error to update the failure status cancel to update the cancellation status
- Parameters:
message
- The message object to be sent.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for remote push notifications.callback
- The callback for sending the message, which carries the object.
-
sendMediaMessage
abstract void sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, IRongCallback.ISendMediaMessageCallbackWithUploader callback)
Sends a multimedia message, allowing you to upload multimedia files to your own server.
When uploading a multimedia file, the callback onAttached is triggered. This callback carries the object. Users only need to call the following methods from this object: update to update the progress, success to update the success status and provide the file URL after successful upload, error to update the failure status, cancel to update the cancellation status.
- Parameters:
message
- The message object to be sent.pushContent
- When sending a remote push notification, this field will be displayed in the notification bar.pushData
- Additional information for remote push notifications.option
- Additional options for sending the message.callback
- The callback for sending the message, which carries the object.- Since:
5.4.4
-
sendReadReceiptRequest
abstract void sendReadReceiptRequest(Message message, RongIMClient.OperationCallback callback)
Initiates a read receipt request for a message (only supported for groups and discussion groups).
Note: You can only initiate a read receipt request for messages you have sent.
- Parameters:
message
- The message for which the read receipt is requestedcallback
- The callback function
-
sendReadReceiptResponse
abstract void sendReadReceiptResponse(ConversationType type, String targetId, List<Message> messageList, RongIMClient.OperationCallback callback)
Send Read Receipt (Supported for Groups and Discussion Groups Only)
- Parameters:
type
- Conversation typetargetId
- Conversation IDmessageList
- List of messages in the conversation for which read receipts need to be sentcallback
- Callback function
-
syncConversationReadStatus
abstract void syncConversationReadStatus(ConversationType type, String targetId, long timestamp, RongIMClient.OperationCallback callback)
Synchronizes the read status of a conversation.
- Parameters:
type
- The type of the conversationtargetId
- The ID of the conversationtimestamp
- The sent timestamp of the last read message in the conversation getSentTimecallback
- The callback function
-
setSyncConversationReadStatusListener
abstract void setSyncConversationReadStatusListener(RongIMClient.SyncConversationReadStatusListener listener)
Sets the listener for multi-device synchronization of conversation read status.
- Parameters:
listener
- The listener for multi-device synchronization of conversation read status SyncConversationReadStatusListener.
-
searchConversations
abstract void searchConversations(String keyword, Array<ConversationType> conversationTypes, Array<String> objectNames, RongIMClient.ResultCallback<List<SearchConversationResult>> resultCallback)
Searches for conversations based on keywords.
This method quickly returns a list of matched conversations, including the number of matched messages in each conversation. Use getMatchCount to retrieve the count.Note: To make custom messages searchable, implement the getSearchableWord method in your custom message class.
- Parameters:
keyword
- The keyword to search for.conversationTypes
- The types of conversations to search.objectNames
- The types of messages to search for, e.g., RC:TxtMsg.resultCallback
- Callback for search results.
-
searchMessages
abstract void searchMessages(ConversationType conversationType, String targetId, String keyword, int count, long beginTime, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages in a specified conversation based on a keyword.
Note: To make custom messages searchable, implement the getSearchableWord method in your custom message class.
- Parameters:
conversationType
- The type of the specified conversation.targetId
- The ID of the specified conversation.keyword
- The keyword to search for.count
- The number of search results to return.beginTime
- Specifies the time before which messages should be searched.resultCallback
- Callback for the search results.
-
searchMessagesByUser
abstract void searchMessagesByUser(ConversationType conversationType, String targetId, String userId, int count, long beginTime, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages in a specified conversation based on the user ID.
Note: To make custom messages searchable, implement the getSearchableWord method in your custom message class.
- Parameters:
conversationType
- The specified conversation type.targetId
- The specified conversation ID.userId
- The user ID.count
- The number of search results to return0 < count <= 100
.beginTime
- The start time for the query.resultCallback
- The callback for search results.
-
getHistoryMessages
abstract void getHistoryMessages(ConversationType conversationType, String targetId, long sentTime, int before, int after, RongIMClient.ResultCallback<List<Message>> resultCallback)
Searches for messages before and after the specified message in a conversation.
The returned message list will include the specified message. The messages are ordered from newest to oldest.
- Parameters:
conversationType
- The specified conversation type.targetId
- The specified conversation ID.sentTime
- The send time of the specified message, which cannot be 0.before
- The number of messages before the specified message.after
- The number of messages after the specified message.resultCallback
- Callback for search results.
-
getVendorToken
abstract void getVendorToken(RongIMClient.ResultCallback<String> resultCallback)
Retrieves the authentication information of the logged-in user.
Third-party vendors use this interface to obtain a token, which is then used along with the vendor's registration information for authentication with the RCserver.
- Parameters:
resultCallback
- The request callback.
-
setPushLanguage
abstract void setPushLanguage(RongIMClient.PushLanguage language, RongIMClient.OperationCallback callback)
Sets the language for remote push notifications. Currently supports Chinese and English.
Note: This feature requires enabling user settings from the server side.
- Parameters:
language
- The language type for remote push notifications, PushLanguage.callback
- The callback for executing the operation.
-
setPushLanguageCode
abstract void setPushLanguageCode(String language, RongIMClient.OperationCallback callback)
Sets the natural language for push notification content.
- Parameters:
language
- The locale set via the SDK, in the format of (ISO-639 Language Code)_(ISO-3166 Country Codes), e.g., zh_CN.callback
- The callback to execute the operation.
-
setPushContentShowStatus
abstract void setPushContentShowStatus(boolean showStatus, RongIMClient.OperationCallback callback)
Sets whether to display the details of remote push notifications.
Note: This feature requires enabling user settings from the server side.
- Parameters:
showStatus
- Indicates whether to display the content of remote push notifications.callback
- The callback function.
-
setPushReceiveStatus
abstract void setPushReceiveStatus(boolean receiveStatus, RongIMClient.OperationCallback callback)
Sets whether to receive remote push notifications.
Prerequisite: The mobile device is offline, while Web and MAC/PC terminals are online. Determines whether the mobile device receives remote push notifications.Note: This feature requires enabling user settings from the server side.
- Parameters:
receiveStatus
- Whether to receive remote push notifications.callback
- Callback
-
getPushLanguage
abstract void getPushLanguage(RongIMClient.ResultCallback<RongIMClient.PushLanguage> callback)
Retrieves the remote push notification language settings.
- Parameters:
callback
- Callback for retrieving the remote push notification language settings, PushLanguage.
-
getPushContentShowStatus
abstract void getPushContentShowStatus(RongIMClient.ResultCallback<Boolean> callback)
Retrieves the setting for displaying detailed content of remote push notifications.
- Parameters:
callback
- Callback to retrieve the setting,true
indicates displaying detailed content,false
indicates not displaying detailed content.
-
getPushReceiveStatus
abstract void getPushReceiveStatus(RongIMClient.ResultCallback<Boolean> callback)
Retrieves the setting for receiving remote push notifications.
Prerequisite: The mobile device is offline, while Web and MAC/PC terminals are online, to determine whether the mobile device receives remote push notifications.
- Parameters:
callback
- Callback to retrieve the setting for receiving remote push notifications,true
to receive remote push notifications,false
to not receive remote push notifications.
-
getOfflineMessageDuration
abstract void getOfflineMessageDuration(RongIMClient.ResultCallback<String> callback)
Retrieves the offline message storage duration (in days).
- Parameters:
callback
- Callback for retrieving the offline message storage duration
-
setOfflineMessageDuration
abstract void setOfflineMessageDuration(int duration, RongIMClient.ResultCallback<Long> callback)
Sets the storage duration of offline messages on the server (in days).
Note: This feature requires the customer to submit a ticket. The client-side method will only take effect after the feature is enabled on the server.
- Parameters:
duration
- The compensation duration for offline messages, ranging from 1 to 7 days.callback
- The callback function
-
setAppVer
abstract void setAppVer(String appVer)
Sets the version information of the user application integrated with the RongCloud SDK.
Note: Must be called after init.
- Parameters:
appVer
- The version information of the user application.
-
supportResumeBrokenTransfer
abstract void supportResumeBrokenTransfer(String url, RongIMClient.ResultCallback<Boolean> callback)
Determines whether resumable upload is supported.
- Parameters:
url
- The file URLcallback
- The callback
-
getTheFirstUnreadMessage
abstract void getTheFirstUnreadMessage(ConversationType conversationType, String targetId, RongIMClient.ResultCallback<Message> callback)
Get the first unread message.
- Parameters:
conversationType
- The type of conversation.targetId
- The ID of the conversation.callback
- The callback function.
-
isFileDownloading
abstract boolean isFileDownloading(int messageId)
Determines whether the file is currently being downloaded.
Note: This method is only applicable for resumable downloads.
- Parameters:
messageId
- The message ID- Returns:
Indicates whether the file is being downloaded
-
isFileDownloading
abstract boolean isFileDownloading(String uid)
Determine whether the file is currently being downloaded.
Note: This method is only applicable for resumable downloads.
- Parameters:
uid
- The file UID, which uniquely identifies the file.- Returns:
Indicates whether the file is being downloaded.
-
setMessageReadTime
abstract void setMessageReadTime(long messageId, long timestamp, RongIMClient.OperationCallback callback)
Sets the read timestamp for a message.
- Parameters:
messageId
- The ID of the message.timestamp
- The timestamp of the message.callback
- The callback for setting the message as read.
-
getVideoLimitTime
abstract int getVideoLimitTime()
Gets the maximum allowed duration for sending video files.
- Returns:
The maximum allowed duration in seconds. Returns -1 if the retrieval fails.
-
getGIFLimitSize
abstract int getGIFLimitSize()
Gets the maximum allowed size for sending GIF images.
- Returns:
Returns the maximum allowed size for sending GIF images in KB. Returns -1 if the retrieval fails.
-
setReconnectKickEnable
abstract void setReconnectKickEnable(boolean enable)
Specifies whether to kick out the reconnecting device during reconnection.
When multi-device login is not enabled for a user, logging in with the same account on a new device will kick out the previously logged-in device. Since the SDK has a reconnection mechanism, the following scenario may occur: A user logs in on device A, but due to unstable network, the connection fails, and the SDK initiates a reconnection. Meanwhile, the user logs in on device B, which successfully connects. When device A's network stabilizes and the user reconnects on device A, device B is kicked out. This interface is designed to handle such scenarios. When
enable
is set totrue
, if the SDK detects that another device has successfully connected during reconnection, it will not forcefully kick out the already connected device but will instead kick out the reconnecting device. This method must be called before init.- Parameters:
enable
- Whether to kick out the reconnecting device
-
appOnStart
abstract void appOnStart()
Notifies the SDK that the application has returned to the foreground.
Note: This method must be called after init.
-
setRLogLevel
abstract void setRLogLevel(int pLevel)
Sets the log level for writing business logs to files.
The interface takes effect immediately.
- Parameters:
pLevel
- The log level.
-
setRLogFileMaxSize
abstract void setRLogFileMaxSize(long pSize)
Sets the size of the business log file, with a default of 1M.
The interface takes effect immediately. When the log file exceeds the specified size, it will be compressed into a zip file and stored locally.
- Parameters:
pSize
- The size of the log file in bytes.
-
setUploadCallback
abstract void setUploadCallback(UploadCallback pCallback)
Sets the callback for uploading RLog logs to the server
- Parameters:
pCallback
- The log upload callback.
-
uploadRLog
abstract void uploadRLog()
Upload RLog logs
Invoke this method after successfully calling connect
-
beginDestructMessage
abstract void beginDestructMessage(Message message, RongIMClient.DestructCountDownTimerListener pListener)
Starts burning the message. Only supports one-to-one chat.
- Parameters:
message
- The message to be burnedpListener
- Countdown callback interface
-
stopDestructMessage
abstract void stopDestructMessage(Message message)
Cancel the burn-after-reading message. Only supported in one-to-one chat.
- Parameters:
message
- The message to cancel burn-after-reading.
-
cancelSDKHeartBeat
abstract void cancelSDKHeartBeat()
Cancel the wakelock heartbeat. This should be called once globally for the entire application after a successful connection.
-
sendPing
abstract void sendPing()
OEM implements heartbeat alignment, sending Ping interface 1. Background WakeLock heartbeat 2. RongPush heartbeat
-
setConversationStatusListener
abstract void setConversationStatusListener(RongIMClient.ConversationStatusListener listener)
Sets up multi-device synchronization monitoring for conversation status (pinned and Do Not Disturb)
- Parameters:
listener
- Multi-device synchronization monitoring for conversation status (pinned and Do Not Disturb) ConversationStatusListener
-
setMessageExpansionListener
abstract void setMessageExpansionListener(RongIMClient.MessageExpansionListener listener)
Sets the message extension listener
- Parameters:
listener
- The message extension listener
-
updateMessageExpansion
abstract void updateMessageExpansion(Map<String, String> expansion, String messageUId, RongIMClient.OperationCallback callback)
Update message extension information
Each message can carry a maximum of 300 key-value pairs of extension information. A single update can set a maximum of 20 key-value pairs.
- Parameters:
expansion
- The key-value pairs of message extension information to be updated, of type HashMap.messageUId
- The message messageUIdcallback
- Callback for updating extension information
-
removeMessageExpansion
abstract void removeMessageExpansion(List<String> keyArray, String messageUId, RongIMClient.OperationCallback callback)
Deletes specific key-value pairs from message extension information.
- Parameters:
keyArray
- List of keys to be deleted from the message extension information, type is ArrayListmessageUId
- The messageUId of the messagecallback
- Callback for deleting message extension information
-
getChatroomHistoryMessages
abstract void getChatroomHistoryMessages(String targetId, long recordTime, int count, RongIMClient.TimestampOrder order, IRongCallback.IChatRoomHistoryMessageCallback callback)
Retrieves chatroom historical messages.
Fetches historical messages of the chatroom from the server. If the specified time is 0, it starts pulling from the first stored message.Note: The chatroom message cloud storage feature must be enabled first.
- Parameters:
targetId
- Conversation ID.recordTime
- The starting message send timestamp in milliseconds.count
- The number of messages to retrieve,0 < count <= 200
.order
- Pull order: descending, from the latest to the earliest; ascending, from the earliest to the latest.callback
- Callback for chatroom historical messages.
-
getChatRoomInfo
abstract void getChatRoomInfo(String chatRoomId, int defMemberCount, ChatRoomMemberOrder order, RongIMClient.ResultCallback<ChatRoomInfo> callback)
Retrieves chatroom information (including partial member information and the total number of members in the chatroom).
Note: Due to the typically large number of members in a chatroom, a balance between efficiency and user experience has been struck. Currently, the returned chatroom information includes member information for no more than 20 members and the total number of members. If you use RC_ChatRoom_Member_Asc in ascending order, the list of members who joined earliest will be returned. If you use RC_ChatRoom_Member_Desc in descending order, the list of members who joined latest will be returned. In both cases, the returned member lists are ordered from oldest to newest based on join time.
- Parameters:
chatRoomId
- The chatroom ID.defMemberCount
- The number of member details to retrieve (currently, the chatroom information includes member details for no more than 20 members, i.e.order
- The order in which chatroom member information is returned.callback
- The status callback.
-
joinChatRoom
abstract void joinChatRoom(String chatRoomId, int defMessageCount, RongIMClient.OperationCallback callback)
Joins a chatroom.
If the chatroom does not exist, the SDK will create and join it. If it already exists, the SDK will join directly. You can specify the number of historical messages to retrieve after successfully joining the chatroom by passing the defMessageCount parameter. -1 indicates no historical messages will be retrieved, 0 indicates no special settings and the SDK will use the default setting (default is 10 messages), and defMessageCount
0 < defMessageCount <= 50
specifies the number of messages to retrieve, with a maximum of 50.- Parameters:
chatRoomId
- The ID of the chatroom.defMessageCount
- The number of messages to pull when entering the chatroom.callback
- The status callback.
-
joinExistChatRoom
abstract void joinExistChatRoom(String chatRoomId, int defMessageCount, RongIMClient.OperationCallback callback)
Join an existing chatroom.
If the chatroom does not exist, joining will fail. When joining a chatroom, you can specify the number of messages to fetch.
- Parameters:
chatRoomId
- The ID of the chatroom.defMessageCount
- The number of messages to fetch when entering the chatroom.callback
- The status callback.- Since:
5.3.1: After joining a chatroom, if the network is disconnected and reconnected, the default number of messages fetched will be the same as the number of historical messages fetched during the initial join. Since the number of messages fetched is fixed, message duplication may occur, and the app needs to handle message deduplication.
-
bindChatRoomWithRTCRoom
abstract void bindChatRoomWithRTCRoom(String chatRoomId, String RTCRoomId, RongIMClient.OperationCallback callback)
Bind chatRoom and RTCRoom. Call this method when you need to invoke ChatRoom while RTCRoom is active.
-
quitChatRoom
abstract void quitChatRoom(String chatRoomId, RongIMClient.OperationCallback callback)
Exits the chatroom.
- Parameters:
chatRoomId
- The ID of the chatroom.callback
- The status callback.
-
setChatRoomEntry
abstract void setChatRoomEntry(String chatRoomId, String key, String value, boolean sendNotification, boolean autoDelete, String notificationExtra, RongIMClient.OperationCallback callback)
Sets custom attributes for a chatroom.
If the key does not exist, the attribute is added; if the key already exists, only the attribute value set by the current user can be updated.Note: The chatroom status storage feature must be enabled first.
- Parameters:
chatRoomId
- The ID of the chatroom.key
- The name of the chatroom attribute.value
- The value corresponding to the chatroom attribute.sendNotification
- Whether to send a notification.autoDelete
- Whether to delete the attribute after exiting the chatroom.notificationExtra
- Custom fields for the notification.callback
- The callback for setting the chatroom attributes.
-
forceSetChatRoomEntry
abstract void forceSetChatRoomEntry(String chatRoomId, String key, String value, boolean sendNotification, boolean autoDelete, String notificationExtra, RongIMClient.OperationCallback callback)
Forcefully sets custom attributes for a chatroom.
If the key does not exist, the attribute is added; if the key already exists, the attribute's value is updated.Note: The chatroom status storage feature must be enabled first.
- Parameters:
chatRoomId
- The ID of the chatroomkey
- The name of the chatroom attribute.value
- The value corresponding to the chatroom attribute, with a maximum length of 4096 characters.sendNotification
- Whether to send a notification.autoDelete
- Whether to delete the attribute after exiting the chatroomnotificationExtra
- Custom fields for the notification.callback
- The callback for setting the chatroom attributes
-
getChatRoomEntry
abstract void getChatRoomEntry(String chatRoomId, String key, RongIMClient.ResultCallback<Map<String, String>> callback)
Retrieves a single attribute of the chatroom.
Note: The chatroom status storage feature must be enabled first.
- Parameters:
chatRoomId
- The ID of the chatroomkey
- The key of the chatroom attributecallback
- The callback listener for the result
-
getAllChatRoomEntries
abstract void getAllChatRoomEntries(String chatRoomId, RongIMClient.ResultCallback<Map<String, String>> callback)
Retrieves all attributes of a chatroom.
Note: The chatroom status storage feature must be enabled first.
- Parameters:
chatRoomId
- The ID of the chatroomcallback
- The result callback listener
-
removeChatRoomEntry
abstract void removeChatRoomEntry(String chatRoomId, String key, Boolean sendNotification, String notificationExtra, RongIMClient.OperationCallback callback)
Deletes chatroom custom attributes.
Note: 1. Chatroom status storage must be enabled first. 2. Only attributes set by yourself can be deleted.
- Parameters:
chatRoomId
- The chatroom ID.key
- The chatroom attribute key.sendNotification
- Whether to send a notification.notificationExtra
- Custom notification field, included in the notification message io.rong.imlib.chatroom.message.callback
- Result callback listener.
-
forceRemoveChatRoomEntry
abstract void forceRemoveChatRoomEntry(String chatRoomId, String key, Boolean sendNotification, String notificationExtra, RongIMClient.OperationCallback callback)
Forces the deletion of chatroom custom attributes.
Note: The chatroom status storage feature must be enabled first.
- Parameters:
chatRoomId
- The chatroom IDkey
- The key of the chatroom attributesendNotification
- Specifies whether to send a notification.notificationExtra
- Custom fields for the notification.callback
- The result callback listener
-
setKVStatusListener
abstract void setKVStatusListener(RongIMClient.KVStatusListener listener)
Sets up a listener for chatroom KV status changes.
- Parameters:
listener
- The listener for chatroom KV status changes KVStatusListener
-
searchPublicService
abstract void searchPublicService(RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Search for public services.
- Parameters:
searchType
- The search type enumeration.keywords
- The search keywords.callback
- The callback for search results.
-
searchPublicServiceByType
abstract void searchPublicServiceByType(PublicServiceType publicServiceType, RongIMClient.SearchType searchType, String keywords, RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Search for public services by public service type.
- Parameters:
publicServiceType
- The type of public service.searchType
- The search type enumeration.keywords
- The search keywords.callback
- The callback for search results.
-
subscribePublicService
abstract void subscribePublicService(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback)
Subscribe to an Official Account.
- Parameters:
publicServiceType
- The type of public service.publicServiceId
- The ID of the public service.callback
- The callback for subscribing to the Official Account.
-
unsubscribePublicService
abstract void unsubscribePublicService(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.OperationCallback callback)
Unsubscribes from an official account.
- Parameters:
publicServiceType
- The type of public service.publicServiceId
- The ID of the public service.callback
- Callback triggered when unsubscribing from the official account.
-
getPublicServiceProfile
abstract void getPublicServiceProfile(PublicServiceType publicServiceType, String publicServiceId, RongIMClient.ResultCallback<PublicServiceProfile> callback)
Retrieves information about a public service.
- Parameters:
publicServiceType
- The type of public service.publicServiceId
- The ID of the public service.callback
- Callback for public account information.
-
getPublicServiceList
abstract void getPublicServiceList(RongIMClient.ResultCallback<PublicServiceProfileList> callback)
Retrieves the list of followed official accounts.
- Parameters:
callback
- Callback for retrieving the list of followed official accounts.
-
getDiscussion
abstract void getDiscussion(String discussionId, RongIMClient.ResultCallback<Discussion> callback)
Retrieve information about a discussion group.
- Parameters:
discussionId
- The ID of the discussion group to retrieve information for.callback
- Callback for retrieving the discussion group.
-
setDiscussionName
abstract void setDiscussionName(String discussionId, String name, RongIMClient.OperationCallback callback)
Sets the name of a discussion group.
- Parameters:
discussionId
- The ID of the discussion group to be set.name
- The name to be set for the discussion group.callback
- The callback for setting the discussion group.
-
createDiscussion
abstract void createDiscussion(String name, List<String> userIdList, RongIMClient.CreateDiscussionCallback callback)
Creates a discussion group.
- Parameters:
name
- The name of the discussion group.userIdList
- The list of member IDs for the discussion group.callback
- The callback triggered upon successful creation of the discussion group.
-
addMemberToDiscussion
abstract void addMemberToDiscussion(String discussionId, List<String> userIdList, RongIMClient.OperationCallback callback)
Adds users to a discussion group.
- Parameters:
discussionId
- The ID of the discussion group.userIdList
- The list of user IDs to be invited.callback
- The callback to execute the operation.
-
removeMemberFromDiscussion
abstract void removeMemberFromDiscussion(String discussionId, String userId, RongIMClient.OperationCallback callback)
Removes a user from a discussion group.
If the currently logged-in user is not the creator of the discussion group and the group does not have open join permissions, an error will be returned. This interface cannot be used to remove oneself; otherwise, an error will be returned. If you need to exit the discussion group, you can use the quitDiscussion method.
- Parameters:
discussionId
- The ID of the discussion group.userId
- The ID of the user.callback
- The operation callback OperationCallback.
-
quitDiscussion
abstract void quitDiscussion(String discussionId, RongIMClient.OperationCallback callback)
Exits the current discussion group.
- Parameters:
discussionId
- The ID of the discussion group.callback
- The callback to execute the operation.
-
setDiscussionInviteStatus
abstract void setDiscussionInviteStatus(String discussionId, RongIMClient.DiscussionInviteStatus status, RongIMClient.OperationCallback callback)
Sets the invitation permissions for discussion group members.
- Parameters:
discussionId
- The ID of the discussion group.status
- The invitation status of the discussion group, defaults to open.callback
- The callback for setting the permissions.
-
getRealTimeLocation
abstract RealTimeLocationErrorCode getRealTimeLocation(ConversationType conversationType, String targetId)
Retrieves an instance of RealTimeLocation.
When used, each time you enter a conversation, retrieve the corresponding instance to determine whether the location sharing service is available or in progress. If the instance retrieval fails, an error code is returned, corresponding to specific failure information. If the retrieval is successful, the user can set up a listener and initiate location sharing. If the retrieval indicates that location sharing is already in progress, it means the other party has initiated location sharing, and the user can set up a listener to join. If other failure information is returned, the user can provide corresponding prompts based on this information.
- Parameters:
conversationType
- The conversation type of the conversation where location sharing is initiated.targetId
- The conversation ID of the conversation where location sharing is initiated.- Returns:
Whether the instance retrieval was successful. RealTimeLocationErrorCode.
-
startRealTimeLocation
abstract RealTimeLocationErrorCode startRealTimeLocation(ConversationType conversationType, String targetId)
Initiates location sharing.
- Parameters:
conversationType
- The type of conversation for which location sharing is initiated.targetId
- The ID of the conversation for which location sharing is initiated.- Returns:
Indicates whether the initiation was successful. Refer to the specific error code RealTimeLocationErrorCode for details.
-
joinRealTimeLocation
abstract RealTimeLocationErrorCode joinRealTimeLocation(ConversationType conversationType, String targetId)
Join location sharing.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.- Returns:
Indicates whether the join operation was successful. Refer to for specific error codes.
-
quitRealTimeLocation
abstract void quitRealTimeLocation(ConversationType conversationType, String targetId)
Exits location sharing.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.
-
getRealTimeLocationParticipants
abstract List<String> getRealTimeLocationParticipants(ConversationType conversationType, String targetId)
Retrieves all members participating in location sharing.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.- Returns:
A list of participant member IDs.
-
getRealTimeLocationCurrentState
abstract RealTimeLocationStatus getRealTimeLocationCurrentState(ConversationType conversationType, String targetId)
Retrieves the status of location sharing.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.- Returns:
The ongoing status of location sharing.
-
addRealTimeLocationListener
abstract void addRealTimeLocationListener(ConversationType conversationType, String targetId, RongIMClient.RealTimeLocationListener listener)
Adds a location sharing listener.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.listener
- The location sharing listener.
-
removeRealTimeLocationObserver
abstract void removeRealTimeLocationObserver(ConversationType conversationType, String targetId)
Removes the location sharing listener.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.
-
updateRealTimeLocationStatus
abstract void updateRealTimeLocationStatus(ConversationType conversationType, String targetId, double latitude, double longitude, RealTimeLocationType realTimeLocationType)
Updates location sharing information.
- Parameters:
conversationType
- The conversation type for location sharing.targetId
- The conversation ID for location sharing.latitude
- The latitude.longitude
- The longitude.realTimeLocationType
- The real-time location sharing type.
-
startCustomService
abstract void startCustomService(String kefuId, ICustomServiceListener listener, CSCustomServiceInfo customServiceInfo)
Starts the customer service.
- Parameters:
kefuId
- The customer service ID, obtained after applying for and enabling the service on the RCdeveloper console.listener
- The customer service listener that monitors the status of the customer service ICustomServiceListener.customServiceInfo
- The customer service user information, including basic user details, contact information, and request details.
-
selectCustomServiceGroup
abstract void selectCustomServiceGroup(String kefuId, String groupId)
Send a message to transfer to human customer support
- Parameters:
kefuId
- Customer support IDgroupId
- Group ID
-
switchToHumanMode
abstract void switchToHumanMode(String kefuId)
Switch to manual customer service mode.
The result of the switch needs to be handled in the onModeChanged callback. If the customer service is not grouped, it will directly switch to manual mode. If the customer service is grouped, you need to pop up a group selection window and select a group in the onSelectGroup callback, and then call selectCustomServiceGroup in this callback to switch to manual mode based on the customer service ID and group ID. The customer service mode io.rong.imlib.cs.model.CustomServiceMode includes no service, bot mode, manual mode, bot-first mode, and manual-first mode.
- Parameters:
kefuId
- The customer service ID, which is obtained after applying for and enabling the service on the RCdeveloper console.
-
evaluateCustomService
abstract void evaluateCustomService(String kefuId, boolean isRobotResolved, String knowledgeId)
Evaluates the customer service bot for separate evaluation of human and bot interactions.
When establishing a customer service connection, if the returned is EVA_SEPARATELY, call this method to evaluate the human customer service.
- Parameters:
kefuId
- The customer service ID, obtained after applying for activation on the RCdeveloper console.isRobotResolved
- Indicates whether the bot resolved the issue.knowledgeId
- The message ID for bot evaluation.
-
evaluateCustomService
abstract void evaluateCustomService(String kefuId, int source, String suggest, String dialogId)
Evaluates the human customer service agent, used for separate evaluation of human and bot agents.
When establishing a customer service connection, if the returned is EVA_SEPARATELY, call this method to evaluate the human customer service agent.
- Parameters:
kefuId
- The customer service agent ID, obtained after applying for and enabling the service on the RCdeveloper console.source
- The rating, ranging from 1 to 5, where 5 is the highest and 1 is the lowest.suggest
- The customer's feedback and suggestions for the human customer service agent.dialogId
- The conversation ID.
-
evaluateCustomService
abstract void evaluateCustomService(String kefuId, int source, CSEvaSolveStatus resolvestatus, String tagText, String suggest, String dialogId, String extra)
Evaluates the customer service bot, allowing separate evaluations for human and bot interactions.
When establishing a customer service connection, if the returned is EVA_SEPARATELY, this method is called to evaluate the human customer service representative.
- Parameters:
kefuId
- The customer service ID, obtained after applying for and enabling the service on the RCdeveloper console.source
- The star rating, ranging from 1 to 5, where 5 is the highest and 1 is the lowest.resolvestatus
- The resolution status CustomServiceConfig.tagText
- Tags for ratings below 5 stars, separated by commas.suggest
- Customer feedback and suggestions for the human customer service representative.dialogId
- The conversation ID.extra
- Reserved for future extensions; can be passed as null.
-
evaluateCustomService
abstract void evaluateCustomService(String kefuId, int source, CSEvaSolveStatus solveStatus, String suggest, String dialogId)
Evaluation for chatbot customer service, used for unified evaluation of both human and chatbot interactions.
When establishing a customer service connection, if the returned is EVA_UNIFIED, call this method to perform the evaluation.
- Parameters:
kefuId
- The customer service ID, obtained after applying for activation on the RCdeveloper console.source
- The star rating, ranging from 1 to 5, where 5 is the highest and 1 is the lowest.solveStatus
- The problem resolution status .suggest
- The customer's feedback and suggestions regarding the human customer service.dialogId
- The conversation ID.
-
leaveMessageCustomService
abstract void leaveMessageCustomService(String kefuId, Map<String, String> contentMap, RongIMClient.OperationCallback operationCallback)
Customer service message.
- Parameters:
kefuId
- The customer service ID, obtained after applying for and enabling the service on the RCdeveloper console.contentMap
- The message content.operationCallback
- Callback indicating whether the message was successfully sent.
-
stopCustomService
abstract void stopCustomService(String kefuId)
Exits the customer support service.
- Parameters:
kefuId
- The customer support ID obtained after applying for and activating the service in the RCdeveloper console.
-
setCustomServiceHumanEvaluateListener
abstract void setCustomServiceHumanEvaluateListener(OnHumanEvaluateListener listener)
Sets up the manual evaluation listener.
When manual evaluation has configurations such as labels, the configurations are returned in the callback.
- Parameters:
listener
- The manual customer support evaluation listener
-
batchInsertMessage
abstract void batchInsertMessage(List<Message> messages, RongIMClient.ResultCallback<Boolean> callback)
Batch inserts received messages (these messages are only inserted into the local database and are not actually sent to the server or the other party). The following attributes of the Message will be stored, while other attributes will be discarded: - conversationType: The type of conversation - targetId: The conversation ID - messageDirection: The direction of the message - senderUserId: The sender's ID - receivedStatus: The received status; if the message direction is inbound and message.getReceivedStatus().setRead() has not been called, the message is unread - sentStatus: The sent status - content: The content of the message - sentTime: The Unix timestamp of when the message was sent, in milliseconds, which affects message sorting
This method does not support the chatroom conversation type. A maximum of 500 messages can be processed per batch; exceeding this limit will return RC_INVALID_PARAMETER_MESSAGE_LIST. The unread count of messages will be accumulated into the conversation's unread count.
- Parameters:
messages
- The list of messages to be processed in batchcallback
- The callback
-
getDownloadInfo
abstract void getDownloadInfo(String tag, RongIMClient.ResultCallback<DownloadInfo> callback)
Retrieves media file download information.
Note: This method is only applicable for resumable downloads.
- Parameters:
tag
- Unique identifier for the file.callback
- Callback
-
setMessageBlockListener
abstract void setMessageBlockListener(MessageBlockListener listener)
Sets the listener for intercepted messages containing sensitive words.
-
setProxy
abstract boolean setProxy(RCIMProxy proxy)
- Returns:
The result of the setting
- Since:
5.3.0
Sets the IM SDK proxy. If the proxy is invalid, the SDK will not automatically detect it and will use the invalid proxy, leading to connection failure. It is recommended to call the testProxy method to test the proxy's availability before calling this method. This method must be called before init. To reset the proxy, you need to call disconnect first, then reset and reconnect. The proxy settings are only stored in memory and are not persisted, so you need to reset them every time the app is launched.
-
getCurrentProxy
abstract RCIMProxy getCurrentProxy()
- Returns:
The currently set proxy
- Since:
5.3.0 Retrieves the currently set proxy
-
testProxy
abstract void testProxy(RCIMProxy proxy, String testHost, RongIMClient.Callback callback)
- Parameters:
proxy
- The proxy.testHost
- The test address, recommended to be set as the domain of the AppServer.callback
- The callback.- Since:
5.3.0 Tests the availability of the proxy.
-
-
-
-