IMCenter

public class IMCenter

Types

Link copied to clipboard
public interface FilterSentListener
Link copied to clipboard
public enum VoiceMessageType
语音消息类型

Functions

Link copied to clipboard
public void addAsyncOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Link copied to clipboard
public void addCancelSendMediaMessageListener(ResultCallback<Message> listener)
Link copied to clipboard
public void addConnectionStatusListener(ConnectionStatusListener listener)
设置连接状态变化的监听器。 当回调状态为TOKEN_INCORRECT, 需要获取正确的token, 并主动调用connect
Link copied to clipboard
public void addConnectStatusListener(ConnectCallback callback)
Link copied to clipboard
public void addConversationEventListener(ConversationEventListener listener)
Link copied to clipboard
public void addConversationStatusListener(ConversationStatusListener listener)
Link copied to clipboard
public void addMessageEventListener(MessageEventListener listener)
Link copied to clipboard
public void addOnRecallMessageListener(OnRecallMessageListener listener)
Link copied to clipboard
public void addOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Link copied to clipboard
public void addReadReceiptListener(ReadReceiptListener listener)
Link copied to clipboard
public void addSyncConversationReadStatusListener(SyncConversationReadStatusListener listener)
Link copied to clipboard
public void addTypingStatusListener(TypingStatusListener listener)
Link copied to clipboard
public void cancelDownloadMediaMessage(Message message, OperationCallback callback)
取消下载多媒体文件。
Link copied to clipboard
public void cancelSendMediaMessage(Message message, OperationCallback callback)
取消发送多媒体文件。
Link copied to clipboard
public void changeMessageReceivedStatus(int messageId, ConversationType conversationType, String targetId, ReceivedStatus status)
Link copied to clipboard
public void cleanHistoryMessages(ConversationIdentifier conversationIdentifier, long recordTime, boolean cleanRemote, OperationCallback callback)
public void cleanHistoryMessages(ConversationType conversationType, String targetId, long recordTime, boolean cleanRemote, OperationCallback callback)
删除指定时间戳之前的消息,可选择是否同时删除服务器端消息 此方法可从服务器端清除历史消息,但是必须先开通历史消息云存储功能。 根据会话类型和会话 id 清除某一会话指定时间戳之前的本地数据库消息(服务端历史消息), 清除成功后只能从本地数据库(服务端)获取到该时间戳之后的历史消息。
Link copied to clipboard
public void clearConversations(ResultCallback callback, Array<ConversationType> conversationTypes)
清空所有会话及会话内的消息,回调方式通知是否清空成功。
Link copied to clipboard
public void clearMessages(ConversationType conversationType, String targetId, ResultCallback<Boolean> callback)
根据会话类型,清空某一会话的所有聊天消息记录,回调方式获取清空是否成功。
Link copied to clipboard
public void clearMessagesUnreadStatus(ConversationIdentifier conversationIdentifier, ResultCallback<Boolean> callback)
public void clearMessagesUnreadStatus(ConversationType conversationType, String targetId, ResultCallback<Boolean> callback)
清除某会话的消息未读状态
Link copied to clipboard
public void clearTextMessageDraft(ConversationType conversationType, String targetId, ResultCallback<Boolean> callback)
清除某一会话的文字消息草稿,回调方式获取清除是否成功。
Link copied to clipboard
public void connect(String token, ConnectCallback connectCallback)

public void connect(String token, int timeLimit, ConnectCallback connectCallback)
连接服务器,在整个应用程序全局,只需要调用一次。 调用该接口,SDK 会在 timeLimit 秒内尝试重连,直到出现下面三种情况之一: 第一、连接成功,回调 onSuccess(userId)。 第二、超时,回调 onError(RC_CONNECT_TIMEOUT),并不再重连。 第三、出现 SDK 无法处理的错误,回调 onError(errorCode)(如 token 非法),并不再重连。 连接成功后,SDK 将接管所有的重连处理。当因为网络原因断线的情况下,SDK 会不停重连直到连接成功为止,不需要您做额外的连接操作。
Link copied to clipboard
public void deleteMessages(ConversationType conversationType, String targetId, ResultCallback<Boolean> callback)
清除指定会话的消息。 此接口会删除指定会话中数据库的所有消息,同时,会清理数据库空间。 如果数据库特别大,超过几百 M,调用该接口会有少许耗时。
public void deleteMessages(ConversationType conversationType, String targetId, Array<int> messageIds, ResultCallback<Boolean> callback)
删除会话里的一条或多条消息。
Link copied to clipboard
public void deleteRemoteMessages(ConversationIdentifier identifier, Array<Message> messages, OperationCallback callback)
public void deleteRemoteMessages(ConversationType conversationType, String targetId, Array<Message> messages, OperationCallback callback)
删除指定的一条或者一组消息。会同时删除本地和远端消息。 请注意,此方法会删除远端消息,请慎重使用 5.6.9版本以下不支持超级群会话类型,从 5.6.
Link copied to clipboard
public void disconnect()
断开连接(断开后继续接收 Push 消息)。
Link copied to clipboard
public void downloadMedia(ConversationType conversationType, String targetId, MediaType mediaType, String imageUrl, DownloadMediaCallback callback)
下载文件。 用来获取媒体原文件时调用。如果本地缓存中包含此文件,则从本地缓存中直接获取,否则将从服务器端下载。
Link copied to clipboard
public void downloadMediaFile(String uid, String fileUrl, String fileName, String path, IDownloadMediaFileCallback callback)
下载文件 支持断点续传
Link copied to clipboard
public void downloadMediaMessage(Message message, IDownloadMediaMessageCallback callback)
下载文件 用来获取媒体原文件时调用。如果本地缓存中包含此文件,则从本地缓存中直接获取,否则将从服务器端下载。
Link copied to clipboard
public Context getContext()
Link copied to clipboard
public ConnectionStatus getCurrentConnectionStatus()
Link copied to clipboard
public static IMCenter getInstance()
Link copied to clipboard
public void handleBeforeSend(Message message)
发送消息之前的内部逻辑处理。
Link copied to clipboard
public static void init(Application application, String appKey, InitOption option)
public static void init(Application application, String appKey, boolean isEnablePush)
public static void init(Application application, String appKey, boolean isEnablePush, Boolean isMainProcess)
初始化 SDK,在整个应用程序全局,只需要调用一次。
Link copied to clipboard
public void insertIncomingMessage(ConversationType type, String targetId, String senderId, ReceivedStatus receivedStatus, MessageContent content, ResultCallback<Message> resultCallback)
public void insertIncomingMessage(ConversationType type, String targetId, String senderId, ReceivedStatus receivedStatus, MessageContent content, long time, ResultCallback<Message> resultCallback)
Link copied to clipboard
public void insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, ResultCallback<Message> resultCallback)
public void insertOutgoingMessage(ConversationIdentifier conversationIdentifier, SentStatus sentStatus, MessageContent content, long time, ResultCallback<Message> resultCallback)
向本地会话中插入一条消息,方向为发送。这条消息只是插入本地会话,不会实际发送给服务器和对方。 插入消息需为入库消息,即 ISPERSISTED,否者会回调 PARAMETER_ERROR
public void insertOutgoingMessage(ConversationType type, String targetId, SentStatus sentStatus, MessageContent content, long time, ResultCallback<Message> resultCallback)
Link copied to clipboard
public boolean isInitialized()
返回 SDK 是否已经初始化。
Link copied to clipboard
public void logout()
注销当前登录,执行该方法后不会再收到 push 消息。
Link copied to clipboard
public void pauseDownloadMediaMessage(Message message, OperationCallback callback)
暂停下载多媒体文件
Link copied to clipboard
public void recallMessage(Message message, String pushContent, ResultCallback callback)
撤回消息
Link copied to clipboard
public void refreshMessage(Message message)
通知会话页面刷新某条消息
Link copied to clipboard
public void removeAsyncOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Link copied to clipboard
public void removeCancelSendMediaMessageListener(ResultCallback<Message> listener)
Link copied to clipboard
public void removeConnectionStatusListener(ConnectionStatusListener listener)
移除连接状态监听器
Link copied to clipboard
public void removeConnectStatusListener(ConnectCallback callback)
Link copied to clipboard
public void removeConversation(ConversationType type, String targetId, ResultCallback<Boolean> callback)
从会话列表中移除某一会话,但是不删除会话内的消息。 如果此会话中有新的消息,该会话将重新在会话列表中显示,并显示最近的历史消息。
Link copied to clipboard
public void removeConversationEventListener(ConversationEventListener listener)
Link copied to clipboard
public void removeConversationStatusListener(ConversationStatusListener listener)
Link copied to clipboard
public void removeMessageEventListener(MessageEventListener listener)
Link copied to clipboard
public void removeOnRecallMessageListener(OnRecallMessageListener listener)
Link copied to clipboard
public void removeOnReceiveMessageListener(OnReceiveMessageWrapperListener listener)
Link copied to clipboard
public void removeReadReceiptListener(ReadReceiptListener listener)
public void removeSyncConversationReadStatusListeners(SyncConversationReadStatusListener listener)
Link copied to clipboard
public void removeTypingStatusListener(TypingStatusListener listener)
Link copied to clipboard
public void saveTextMessageDraft(ConversationIdentifier conversationIdentifier, String content, ResultCallback<Boolean> callback)
public void saveTextMessageDraft(ConversationType conversationType, String targetId, String content, ResultCallback<Boolean> callback)
保存文字消息草稿,回调方式获取保存是否成功。
Link copied to clipboard
public void sendDirectionalMediaMessage(Message message, Array<String> userIds, String pushContent, String pushData, ISendMediaMessageCallback callback)
发送定向多媒体消息 向会话中特定的某些用户发送消息,会话中其他用户将不会收到此消息。 发送前构造 Message 消息实体,消息实体中的 content 必须为多媒体消息,如 ImageMessage或者其他继承自 MediaMessageContent 的消息 从 5.6.
Link copied to clipboard
public void sendDirectionalMessage(Message message, Array<String> userIds, String pushContent, String pushData, ISendMessageCallback callback)

public void sendDirectionalMessage(ConversationType type, String targetId, MessageContent content, Array<String> userIds, String pushContent, String pushData, ISendMessageCallback callback)
发送定向消息。向会话中特定的某些用户发送消息,会话中其他用户将不会收到此消息。 通过 IRongCallback.
Link copied to clipboard
public void sendLocationMessage(Message message, String pushContent, String pushData, ISendMessageCallback sendMessageCallback)
发送地理位置消息。并同时更新界面。 发送前构造 Message 消息实体,消息实体中的 content 必须为 LocationMessage, 否则返回失败。 其中的缩略图地址 scheme 只支持 file:// 和 http:// 其他暂不支持。
Link copied to clipboard
public void sendMediaMessage(Message message, String pushContent, String pushData, ISendMediaMessageCallback callback)
public void sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, ISendMediaMessageCallback callback)
发送消息。 通过 IRongCallback.
public void sendMediaMessage(Message message, String pushContent, String pushData, ISendMediaMessageCallbackWithUploader callback)
public void sendMediaMessage(Message message, String pushContent, String pushData, SendMessageOption option, ISendMediaMessageCallbackWithUploader callback)
Link copied to clipboard
public void sendMessage(Message message, String pushContent, String pushData, ISendMessageCallback callback)
public void sendMessage(Message message, String pushContent, String pushData, SendMessageOption option, ISendMessageCallback callback)
发送消息。 通过 IRongCallback.
public void sendMessage(ConversationType type, String targetId, MessageContent content, String pushContent, String pushData, ISendMessageCallback callback)
根据会话类型,发送消息。 通过 IRongCallback.
Link copied to clipboard
public void sendReadReceiptMessage(ConversationType conversationType, String targetId, long timestamp, ISendMessageCallback callback)
发送已读回执,该方法会触发刷新消息未读数 通过 IRongCallback.
Link copied to clipboard
public static void setConversationClickListener(ConversationClickListener listener)
设置会话界面操作的监听器。
Link copied to clipboard
public static void setConversationListBehaviorListener(ConversationListBehaviorListener listener)
设置会话列表界面操作的监听器。
Link copied to clipboard
public void setConversationNotificationStatus(ConversationIdentifier conversationIdentifier, ConversationNotificationStatus notificationStatus, ResultCallback<ConversationNotificationStatus> callback)
public void setConversationNotificationStatus(ConversationType conversationType, String targetId, ConversationNotificationStatus notificationStatus, ResultCallback<ConversationNotificationStatus> callback)
设置会话消息提醒状态。
Link copied to clipboard
public void setConversationToTop(ConversationIdentifier conversationIdentifier, boolean isTop, ResultCallback<Boolean> callback)
@Deprecated()
public void setConversationToTop(ConversationIdentifier conversationIdentifier, boolean isTop, boolean needCreate, ResultCallback<Boolean> callback)
@Deprecated()
public void setConversationToTop(ConversationType type, String targetId, boolean isTop, boolean needCreate, ResultCallback<Boolean> callback)
设置某一会话为置顶或者取消置顶,回调方式获取设置是否成功。
Link copied to clipboard
public void setMessageInterceptor(MessageInterceptor messageInterceptor)
设置接收消息时的拦截器
Link copied to clipboard
public void setMessageSentStatus(Message message, ResultCallback<Boolean> callback)
根据消息 Message 设置消息状态,回调方式获取设置是否成功。
Link copied to clipboard
public void supportResumeBrokenTransfer(String url, ResultCallback<Boolean> callback)
判断是否支持断点续传。
Link copied to clipboard
public void syncConversationReadStatus(ConversationIdentifier conversationIdentifier, long timestamp, OperationCallback callback)
public void syncConversationReadStatus(ConversationType type, String targetId, long timestamp, OperationCallback callback)
同步会话阅读状态。