import { NativeModules, Platform, NativeEventEmitter, DeviceEventEmitter } from 'react-native'; const isTurboModuleEnabled = global.__turboModuleProxy != null; const RCReactNativeIM = isTurboModuleEnabled ? require('./NativeReactNativeImWrapper').default : NativeModules.RCReactNativeIM; const RCReactNativeEventEmitter = Platform.OS === 'ios' ? new NativeEventEmitter(RCReactNativeIM) : DeviceEventEmitter; import { RCIMIWEngineOptions } from './RCIMDefines'; import { logger } from './Logger'; import { IRCIMIWAddChatRoomEntriesCallback, IRCIMIWAddChatRoomEntryCallback, IRCIMIWAddConversationToTagCallback, IRCIMIWAddToBlacklistCallback, IRCIMIWCancelDownloadingMediaMessageCallback, IRCIMIWCancelSendingMediaMessageCallback, IRCIMIWChangeConversationNotificationLevelCallback, IRCIMIWChangeConversationTopStatusCallback, IRCIMIWChangeConversationTopStatusInTagCallback, IRCIMIWChangeConversationTypeNotificationLevelCallback, IRCIMIWChangeMessageReceivedStatusCallback, IRCIMIWChangeMessageReceivedStatusInfoCallback, IRCIMIWChangeMessageSentStatusCallback, IRCIMIWChangeNotificationQuietHoursCallback, IRCIMIWChangePushContentShowStatusCallback, IRCIMIWChangePushLanguageCallback, IRCIMIWChangePushReceiveStatusCallback, IRCIMIWChangeUltraGroupChannelDefaultNotificationLevelCallback, IRCIMIWChangeUltraGroupDefaultNotificationLevelCallback, IRCIMIWClearConversationsByTagCallback, IRCIMIWClearDraftMessageCallback, IRCIMIWClearMessagesCallback, IRCIMIWClearMessagesUnreadStatusByTagCallback, IRCIMIWClearUltraGroupMessagesCallback, IRCIMIWClearUltraGroupMessagesForAllChannelCallback, IRCIMIWClearUnreadCountCallback, IRCIMIWCreateTagCallback, IRCIMIWDeleteLocalMessageByIdsCallback, IRCIMIWDeleteLocalMessagesCallback, IRCIMIWDeleteMessagesCallback, IRCIMIWGetBatchRemoteUltraGroupMessagesCallback, IRCIMIWGetBlacklistCallback, IRCIMIWGetBlacklistStatusCallback, IRCIMIWGetBlockedConversationsCallback, IRCIMIWGetChatRoomAllEntriesCallback, IRCIMIWGetChatRoomEntryCallback, IRCIMIWGetChatRoomMessagesCallback, IRCIMIWGetConversationCallback, IRCIMIWGetConversationNotificationLevelCallback, IRCIMIWGetConversationTopStatusCallback, IRCIMIWGetConversationTopStatusInTagCallback, IRCIMIWGetConversationTypeNotificationLevelCallback, IRCIMIWGetConversationsCallback, IRCIMIWGetConversationsForAllChannelCallback, IRCIMIWGetDraftMessageCallback, IRCIMIWGetFirstUnreadMessageCallback, IRCIMIWGetMessageCallback, IRCIMIWGetMessageCountCallback, IRCIMIWGetMessagesAroundTimeCallback, IRCIMIWGetMessagesCallback, IRCIMIWGetNotificationQuietHoursCallback, IRCIMIWGetTagsCallback, IRCIMIWGetTagsFromConversationCallback, IRCIMIWGetTopConversationsCallback, IRCIMIWGetTotalUnreadCountCallback, IRCIMIWGetUltraGroupAllUnreadCountCallback, IRCIMIWGetUltraGroupAllUnreadMentionedCountCallback, IRCIMIWGetUltraGroupChannelDefaultNotificationLevelCallback, IRCIMIWGetUltraGroupDefaultNotificationLevelCallback, IRCIMIWGetUltraGroupUnreadCountCallback, IRCIMIWGetUltraGroupUnreadMentionedCountCallback, IRCIMIWGetUnreadConversationsCallback, IRCIMIWGetUnreadCountByConversationTypesCallback, IRCIMIWGetUnreadCountByLevelsCallback, IRCIMIWGetUnreadCountCallback, IRCIMIWGetUnreadMentionedCountCallback, IRCIMIWGetUnreadMentionedMessagesCallback, IRCIMIWInsertMessageCallback, IRCIMIWInsertMessagesCallback, IRCIMIWJoinChatRoomCallback, IRCIMIWLeaveChatRoomCallback, IRCIMIWModifyUltraGroupMessageCallback, IRCIMIWOperationCallback, IRCIMIWRecallMessageCallback, IRCIMIWRecallUltraGroupMessageCallback, IRCIMIWRemoveChatRoomEntriesCallback, IRCIMIWRemoveChatRoomEntryCallback, IRCIMIWRemoveConversationCallback, IRCIMIWRemoveConversationFromTagCallback, IRCIMIWRemoveConversationsCallback, IRCIMIWRemoveFromBlacklistCallback, IRCIMIWRemoveMessageExpansionForKeysCallback, IRCIMIWRemoveNotificationQuietHoursCallback, IRCIMIWRemoveTagCallback, IRCIMIWRemoveTagsFromConversationCallback, IRCIMIWRemoveUltraGroupMessageExpansionForKeysCallback, IRCIMIWSaveDraftMessageCallback, IRCIMIWSearchConversationsCallback, IRCIMIWSearchMessagesByMessageTypesCallback, IRCIMIWSearchMessagesByTimeRangeCallback, IRCIMIWSearchMessagesByUserIdCallback, IRCIMIWSearchMessagesCallback, IRCIMIWSendGroupReadReceiptRequestCallback, IRCIMIWSendGroupReadReceiptResponseCallback, IRCIMIWSendPrivateReadReceiptMessageCallback, IRCIMIWSendUltraGroupTypingStatusCallback, IRCIMIWSyncConversationReadStatusCallback, IRCIMIWSyncUltraGroupReadStatusCallback, IRCIMIWUpdateMessageExpansionCallback, IRCIMIWUpdateMessageLocalExtraCallback, IRCIMIWUpdateTagNameByIdCallback, IRCIMIWUpdateUltraGroupMessageExpansionCallback, RCIMIWAppSettings, RCIMIWBlacklistStatus, RCIMIWBlockedMessageInfo, RCIMIWChatRoomEntriesOperationType, RCIMIWChatRoomMemberAction, RCIMIWChatRoomMemberBanEvent, RCIMIWChatRoomMemberBlockEvent, RCIMIWChatRoomStatus, RCIMIWChatRoomSyncEvent, RCIMIWConnectCallback, RCIMIWConnectionStatus, RCIMIWConversation, RCIMIWConversationType, RCIMIWCustomMessage, RCIMIWCustomMessagePolicy, RCIMIWDownloadMediaMessageListener, RCIMIWFileMessage, RCIMIWGIFMessage, RCIMIWImageMessage, RCIMIWLocationMessage, RCIMIWLogLevel, RCIMIWMediaMessage, RCIMIWMessage, RCIMIWMessageOperationPolicy, RCIMIWMessageType, RCIMIWNativeCustomMediaMessage, RCIMIWNativeCustomMessage, RCIMIWNativeCustomMessagePersistentFlag, RCIMIWPushNotificationLevel, RCIMIWPushNotificationQuietHoursLevel, RCIMIWReceivedStatus, RCIMIWReceivedStatusInfo, RCIMIWReferenceMessage, RCIMIWSearchConversationResult, RCIMIWSendGroupMessageToDesignatedUsersCallback, RCIMIWSendMediaMessageListener, RCIMIWSendMessageCallback, RCIMIWSentStatus, RCIMIWSightMessage, RCIMIWTextMessage, RCIMIWTimeOrder, RCIMIWTypingStatus, RCIMIWUltraGroupTypingStatus, RCIMIWUltraGroupTypingStatusInfo, RCIMIWVoiceMessage, } from './RCIMDefines'; export class RCIMIWEngine { static _instance: RCIMIWEngine | null; /** * 创建接口引擎 * * @param context 上下文 * @param appKey 开发者后台获取的 AppKey * @param options 引擎配置项 * @return 引擎实例 */ static create(appKey: string, options: RCIMIWEngineOptions = {}): RCIMIWEngine { logger.logObject('create', { appKey, options }); if (!RCIMIWEngine._instance) { RCReactNativeIM.create(appKey, options); RCIMIWEngine._instance = new RCIMIWEngine(); } return RCIMIWEngine._instance; } /** * 销毁引擎 * 引擎销毁后如果当前未退出登录,SDK 会自动退出,且仍接受 push */ destroy(): Promise { logger.logObject('destroy', {}); RCIMIWEngine._instance = null; return RCReactNativeIM.destroy(); } setDeviceToken(deviceToken: string): Promise { logger.logObject('setDeviceToken', { deviceToken }); if (Platform.OS === 'ios') { return RCReactNativeIM.setDeviceToken(deviceToken); } else { return new Promise((resolve, reject) => { resolve(0); }); } } /** * [ZH] * --- * 注册原生自定义普通消息 * @param messageIdentifier 消息的唯一标识 * @param persistentFlag 消息的存储策略 * @return 当次接口操作的状态码。0 代表调用成功,非 0 代表当前接口调用操作失败,详细错误参考错误码 * --- * [EN] * --- * Register Native Custom Message * @param messageIdentifier The unique identifier of the message * @param persistentFlag The storage strategy of the message * @return The status code of the current operation. 0 indicates success, * non-zero indicates failure. Refer to the error codes for detailed * error information. * --- */ registerNativeCustomMessage( messageIdentifier: string, persistentFlag: RCIMIWNativeCustomMessagePersistentFlag, ): Promise { logger.logObject('registerNativeCustomMessage', { messageIdentifier, persistentFlag }); return RCReactNativeIM.registerNativeCustomMessage(messageIdentifier, persistentFlag); } /** * [ZH] * --- * 注册原生自定义媒体消息 * @param messageIdentifier 消息的唯一标识 * @param persistentFlag 消息的存储策略 * @return 当次接口操作的状态码。0 代表调用成功,非 0 代表当前接口调用操作失败,详细错误参考错误码 * --- * [EN] * --- * Register Native Custom Media Message * @param messageIdentifier The unique identifier of the message. * @param persistentFlag The storage strategy of the message. * @return The status code of the current operation. `0` indicates success, * while non-zero values indicate failure. Refer to the error codes for * detailed error information. * --- */ registerNativeCustomMediaMessage( messageIdentifier: string, persistentFlag: RCIMIWNativeCustomMessagePersistentFlag, ): Promise { logger.logObject('registerNativeCustomMediaMessage', { messageIdentifier, persistentFlag }); return RCReactNativeIM.registerNativeCustomMediaMessage(messageIdentifier, persistentFlag); } /** * [ZH] * --- * 连接融云服务器,在整个应用程序全局,只需要调用一次。调用此接口返回非业务错误码时,SDK * 会启动重连机制进行重连;如果仍没有连接成功,会在设备网络状态变化时再次进行重连。 * @param token 调用 server api 获取到的 token * @param timeout 连接超时时间,单位:秒。 * timeout ≤ 0,则 IM 将一直连接,直到连接成功或者无法连接(如 token 非法) * timeout > 0,则 IM 将最多连接 timeout 秒 * 如果在 timeout 秒内连接成功,后面再发生了网络变化或前后台切换,SDK 会自动重连; 如果在 timeout * 秒无法连接成功则不再进行重连,通过 listener 告知连接超时,您需要再自行调用 connect 接口 * @param callback 链接事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Connect to the RongCloud server. This interface should be called * only once globally throughout the application. When this interface * returns a non-business error code, the SDK will initiate a * reconnection mechanism. If the connection is still unsuccessful, * the SDK will attempt to reconnect when the device's network status * changes. * @param token The token obtained by calling the server API. * @param timeout Connection timeout duration in seconds. * If timeout ≤ 0, the IM will keep trying to connect until it * succeeds or fails (e.g., due to an invalid token). * If timeout > 0, the IM will attempt to connect for a maximum * of timeout seconds. * If the connection is successful within timeLimit seconds, the * SDK will automatically reconnect in case of network changes * or app state transitions. If the connection fails within * timeLimit seconds, no further reconnection attempts will be * made, and the listener will notify of a connection timeout. * You will need to manually call the connect interface again. * @param callback Connection event callback. The SDK has supported * callback-style callbacks since version 5.3.1. Other callback * methods for this interface were deprecated in version 5.4.0 * and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. A non-zero value indicates that the current * interface call operation failed, and no interface callback will be * triggered. Refer to the error codes for detailed error information. * --- */ connect(token: string, timeout: number, callback?: RCIMIWConnectCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onDatabaseOpened, onConnected } = callback; if (onDatabaseOpened) { const eventEmitter = RCReactNativeEventEmitter.addListener('Connect:onDatabaseOpened', (data: any) => { if (data?.eventId === eventId) { onDatabaseOpened && onDatabaseOpened(data?.code); eventEmitter.remove(); } }); } if (onConnected) { const eventEmitter = RCReactNativeEventEmitter.addListener('Connect:onConnected', (data: any) => { if (data?.eventId === eventId) { onConnected && onConnected(data?.code, data?.userId); eventEmitter.remove(); } }); } } logger.logObject('connect', { token, timeout, callback, eventId }); return RCReactNativeIM.connect(token, timeout, eventId); } /** * [ZH] * --- * 断开链接 * 注:因为 SDK 在前后台切换或者网络出现异常都会自动重连,保证连接可靠性。 所以除非您的 App 逻辑需要登出,否则一般不需要调用此方法进行手动断开 * @param receivePush 退出后是否接收 push,true:断开后接收远程推送,false:断开后不再接收远程推送 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Disconnect * Note: Since the SDK automatically reconnects when the app switches * between foreground and background or when network exceptions occur, * ensuring connection reliability, this method is generally not * required for manual disconnection unless your app logic requires * logout. * @param receivePush Specifies whether to receive push notifications after * disconnection. true: continue receiving remote push * notifications after disconnection; false: stop receiving * remote push notifications after disconnection. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled through the * interface callback. Non-zero indicates that the current operation * failed, and the interface callback will not be triggered. Refer to * the error codes for detailed error information. * --- */ disconnect(receivePush: boolean): Promise { logger.logObject('disconnect', { receivePush }); return RCReactNativeIM.disconnect(receivePush); } /** * [ZH] * --- * 获取当前 IM 服务连接状态 * @return 当前连接状态 * --- * [EN] * --- * Get current IM service connection status * @return Current connection status * --- */ getConnectionStatus(): Promise { logger.logObject('getConnectionStatus', {}); return RCReactNativeIM.getConnectionStatus(); } /** * [ZH] * --- * 构建文本消息 * @param type 会话类型, * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param text 文本内容 * @return 文本消息实体 * --- * [EN] * --- * Build Text Message * @param type Specifies the conversation type. * @param targetId Specifies the conversation ID. * @param channelId Specifies the channel ID, which is only supported for ultra * groups. For other conversation types, pass `null`. * @param text Specifies the text content. * @return Returns the text message object. * --- */ createTextMessage( type: RCIMIWConversationType, targetId: string, channelId: string, text: string, ): Promise { logger.logObject('createTextMessage', { type, targetId, channelId, text }); return RCReactNativeIM.createTextMessage(type, targetId, channelId, text); } /** * [ZH] * --- * 构建图片消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param path 图片消息的本地路径,必须为有效路径 * @return 图片消息实体 * --- * [EN] * --- * Create an Image Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param path Local path of the image message. Must be a valid path. * @return Image message object * --- */ createImageMessage( type: RCIMIWConversationType, targetId: string, channelId: string, path: string, ): Promise { logger.logObject('createImageMessage', { type, targetId, channelId, path }); return RCReactNativeIM.createImageMessage(type, targetId, channelId, path); } /** * [ZH] * --- * 构建文件消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param path 文件消息的本地路径,必须为有效路径 * @return 文件消息实体 * --- * [EN] * --- * Build File Message * @param type Specifies the conversation type. * @param targetId Specifies the conversation ID. * @param channelId Specifies the channel ID, which is only supported for ultra * groups. For other conversation types, pass null. * @param path Specifies the local path of the file message, which must be * a valid path. * @return Returns the file message object. * --- */ createFileMessage( type: RCIMIWConversationType, targetId: string, channelId: string, path: string, ): Promise { logger.logObject('createFileMessage', { type, targetId, channelId, path }); return RCReactNativeIM.createFileMessage(type, targetId, channelId, path); } /** * [ZH] * --- * 构建小视频消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param path 小视频消息的本地路径,必须为有效路径 * @param duration 小视频消息的视频时长 * @return 视频消息实体 * --- * [EN] * --- * Build Short Video Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param path Local path of the short video message. Must be a valid path. * @param duration Duration of the short video message * @return Video message object * --- */ createSightMessage( type: RCIMIWConversationType, targetId: string, channelId: string, path: string, duration: number, ): Promise { logger.logObject('createSightMessage', { type, targetId, channelId, path, duration }); return RCReactNativeIM.createSightMessage(type, targetId, channelId, path, duration); } /** * [ZH] * --- * 构建语音消息 (高清语音) * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param path 语音消息的本地路径,必须为有效路径 * @param duration 语音消息的消息时长 * @return 语音消息的实体 * --- * [EN] * --- * Build a Voice Message (HD Voice) * @param type Specifies the conversation type. * @param targetId Specifies the conversation ID. * @param channelId Specifies the channel ID. Only supported for ultra groups. * For other conversation types, pass null. * @param path Specifies the local path of the voice message. Must be a * valid path. * @param duration Specifies the duration of the voice message. * @return Returns the voice message object. * --- */ createVoiceMessage( type: RCIMIWConversationType, targetId: string, channelId: string, path: string, duration: number, ): Promise { logger.logObject('createVoiceMessage', { type, targetId, channelId, path, duration }); return RCReactNativeIM.createVoiceMessage(type, targetId, channelId, path, duration); } /** * [ZH] * --- * 构建引用消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param referenceMessage 引用的消息 * @param text 引用的文本内容 * @return 引用消息实体 * --- * [EN] * --- * Construct a reference message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For * other conversation types, pass null. * @param referenceMessage The referenced message * @param text The referenced text content * @return The reference message object * --- */ createReferenceMessage( type: RCIMIWConversationType, targetId: string, channelId: string, referenceMessage: RCIMIWMessage, text: string, ): Promise { logger.logObject('createReferenceMessage', { type, targetId, channelId, referenceMessage, text }); return RCReactNativeIM.createReferenceMessage(type, targetId, channelId, referenceMessage, text); } /** * [ZH] * --- * 构建 GIF 消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param path GIF 消息的本地路径 * @return GIF 消息实体 * --- * [EN] * --- * Build GIF Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param path Local path of the GIF message * @return GIF message object * --- */ createGIFMessage( type: RCIMIWConversationType, targetId: string, channelId: string, path: string, ): Promise { logger.logObject('createGIFMessage', { type, targetId, channelId, path }); return RCReactNativeIM.createGIFMessage(type, targetId, channelId, path); } /** * [ZH] * --- * 构建自定义消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param policy 消息的存储策略 * @param messageIdentifier 消息的标识符,需唯一 * @param fields 消息的内容键值对 * @return 自定义消息实体 * --- * [EN] * --- * Build Custom Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass * null for other conversation types. * @param policy Message storage policy * @param messageIdentifier Message identifier, must be unique * @param fields Key-value pairs of message content * @return Custom message entity * --- */ createCustomMessage( type: RCIMIWConversationType, targetId: string, channelId: string, policy: RCIMIWCustomMessagePolicy, messageIdentifier: string, fields: Map, ): Promise { let _fields: any = Object.fromEntries(fields); logger.logObject('createCustomMessage', { type, targetId, channelId, policy, messageIdentifier, fields }); return RCReactNativeIM.createCustomMessage(type, targetId, channelId, policy, messageIdentifier, _fields); } /** * [ZH] * --- * 构建位置消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param longitude 经度 * @param latitude 纬度 * @param poiName POI 信息 * @param thumbnailPath 缩略图本地路径,必须为有效路径 * @return 位置消息实体 * --- * [EN] * --- * Construct Location Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null * for other conversation types. * @param longitude Longitude * @param latitude Latitude * @param poiName POI information * @param thumbnailPath Local path of the thumbnail, must be a valid path * @return Location message entity * --- */ createLocationMessage( type: RCIMIWConversationType, targetId: string, channelId: string, longitude: number, latitude: number, poiName: string, thumbnailPath: string, ): Promise { logger.logObject('createLocationMessage', { type, targetId, channelId, longitude, latitude, poiName, thumbnailPath, }); return RCReactNativeIM.createLocationMessage( type, targetId, channelId, longitude, latitude, poiName, thumbnailPath, ); } /** * [ZH] * --- * 构建原生自定义普通消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param messageIdentifier 消息的标识符,需唯一 * @param fields 消息的内容键值对 * @return 原生自定义普通消息 * --- * [EN] * --- * Build Native Custom Regular Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass * null for other conversation types. * @param messageIdentifier Unique identifier for the message * @param fields Key-value pairs for the message content * @return Native custom regular message * --- */ createNativeCustomMessage( type: RCIMIWConversationType, targetId: string, channelId: string, messageIdentifier: string, fields: Map, ): Promise { let _fields: any = Object.fromEntries(fields); logger.logObject('createNativeCustomMessage', { type, targetId, channelId, messageIdentifier, fields }); return RCReactNativeIM.createNativeCustomMessage(type, targetId, channelId, messageIdentifier, _fields); } /** * [ZH] * --- * 构建原生自定义媒体消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param messageIdentifier 消息的标识符,需唯一 * @param path 媒体文件的本地路径,必须为有效路径 * @param fields 消息的内容键值对 * @return 原生自定义媒体消息 * --- * [EN] * --- * Build Native Custom Media Message * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass * null for other conversation types. * @param messageIdentifier Unique identifier for the message * @param path Local path of the media file, must be a valid path * @param fields Key-value pairs for the message content * @return Native custom media message * --- */ createNativeCustomMediaMessage( type: RCIMIWConversationType, targetId: string, channelId: string, messageIdentifier: string, path: string, fields: Map, ): Promise { let _fields: any = Object.fromEntries(fields); logger.logObject('createNativeCustomMediaMessage', { type, targetId, channelId, messageIdentifier, path, fields, }); return RCReactNativeIM.createNativeCustomMediaMessage( type, targetId, channelId, messageIdentifier, path, _fields, ); } /** * [ZH] * --- * 发送普通消息 * @param message 发送的消息实体 * @param callback 发送消息的事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send a Normal Message * @param message The message object to be sent. * @param callback The event callback for sending the message. The SDK supports * callback-based responses starting from version 5.3.1. Other * callback methods for this interface are deprecated as of * version 5.4.0 and are expected to be removed in version 6.x. * If the callback parameter is provided, only the callback will * be triggered. * @return The status code of the current operation. A value of 0 indicates a * successful call, and the specific result needs to be handled via the * interface callback. A non-zero value indicates that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * [onMessageSent]. * --- */ sendMessage(message: RCIMIWMessage, callback?: RCIMIWSendMessageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageSaved, onMessageSent } = callback; if (onMessageSaved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendMessage:onMessageSaved', (data: any) => { if (data?.eventId === eventId) { onMessageSaved && onMessageSaved(data?.message); eventEmitter.remove(); } }, ); } if (onMessageSent) { const eventEmitter = RCReactNativeEventEmitter.addListener('SendMessage:onMessageSent', (data: any) => { if (data?.eventId === eventId) { onMessageSent && onMessageSent(data?.code, data?.message); eventEmitter.remove(); } }); } } logger.logObject('sendMessage', { message, callback, eventId }); return RCReactNativeIM.sendMessage(message, eventId); } /** * [ZH] * --- * 发送媒体消息 * @param message 发送的媒体消息实体 * @param listener 发送媒体消息的事件监听 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * [onMediaMessageSending],[onMediaMessageAttached],[onMediaMessageSent] * --- * [EN] * --- * Send Media Message * @param message The media message object to be sent * @param listener Event listener for sending media messages * @return Status code of the current API operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * interface callback. Non-zero indicates that the current API call * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed errors. * [onMediaMessageAttached], [onMediaMessageSent] * --- */ sendMediaMessage(message: RCIMIWMediaMessage, listener?: RCIMIWSendMediaMessageListener): Promise { const eventId = Math.random().toString(); if (listener) { const { onMediaMessageSaved, onMediaMessageSending, onSendingMediaMessageCanceled, onMediaMessageSent } = listener; if (onMediaMessageSaved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendMediaMessage:onMediaMessageSaved', (data: any) => { if (data?.eventId === eventId) { onMediaMessageSaved && onMediaMessageSaved(data?.message); eventEmitter.remove(); } }, ); } let onMediaMessageSendingEmitter; if (onMediaMessageSending) { onMediaMessageSendingEmitter = RCReactNativeEventEmitter.addListener( 'SendMediaMessage:onMediaMessageSending', (data: any) => { if (data?.eventId === eventId) { onMediaMessageSending && onMediaMessageSending(data?.message, data?.progress); } }, ); } if (onSendingMediaMessageCanceled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendMediaMessage:onSendingMediaMessageCanceled', (data: any) => { if (data?.eventId === eventId) { onSendingMediaMessageCanceled && onSendingMediaMessageCanceled(data?.message); eventEmitter.remove(); if (onMediaMessageSendingEmitter) { onMediaMessageSendingEmitter.remove(); } } }, ); } if (onMediaMessageSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendMediaMessage:onMediaMessageSent', (data: any) => { if (data?.eventId === eventId) { onMediaMessageSent && onMediaMessageSent(data?.code, data?.message); eventEmitter.remove(); if (onMediaMessageSendingEmitter) { onMediaMessageSendingEmitter.remove(); } } }, ); } } logger.logObject('sendMediaMessage', { message, listener, eventId }); return RCReactNativeIM.sendMediaMessage(message, eventId); } /** * [ZH] * --- * 取消发送媒体消息 * @param message 需要取消发送的媒体消息实体 * @param callback 取消发送媒体消息的事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Cancel Sending Media Message * @param message The media message entity to be canceled * @param callback The event callback for canceling the media message. The SDK * supports callback mode starting from version 5.3.1. Other * callback methods for this interface are deprecated in version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current operation. 0 indicates the call was * successful, and the specific result requires implementing the * interface callback. Non-zero indicates the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * [onSendingMediaMessageCanceled] * --- */ cancelSendingMediaMessage( message: RCIMIWMediaMessage, callback?: IRCIMIWCancelSendingMediaMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onCancelSendingMediaMessageCalled } = callback; if (onCancelSendingMediaMessageCalled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'CancelSendingMediaMessage:onCancelSendingMediaMessageCalled', (data: any) => { if (data?.eventId === eventId) { onCancelSendingMediaMessageCalled && onCancelSendingMediaMessageCalled(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('cancelSendingMediaMessage', { message, callback, eventId }); return RCReactNativeIM.cancelSendingMediaMessage(message, eventId); } /** * [ZH] * --- * 下载媒体消息 * @param message 需要下载的媒体消息实体 * @param listener 下载媒体消息的事件监听 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Download Media Message * @param message The media message entity to be downloaded * @param listener The event listener for media message download * @return The status code of the current operation. 0 indicates success, and * the specific result needs to be obtained through the interface * callback. Non-zero indicates that the current operation failed, and * no callback will be triggered. Refer to the error codes for detailed * error information. * --- */ downloadMediaMessage(message: RCIMIWMediaMessage, listener?: RCIMIWDownloadMediaMessageListener): Promise { const eventId = Math.random().toString(); if (listener) { const { onMediaMessageDownloading, onDownloadingMediaMessageCanceled, onMediaMessageDownloaded } = listener; let onMediaMessageDownloadingEmitter; if (onMediaMessageDownloading) { onMediaMessageDownloadingEmitter = RCReactNativeEventEmitter.addListener( 'DownloadMediaMessage:onMediaMessageDownloading', (data: any) => { if (data?.eventId === eventId) { onMediaMessageDownloading && onMediaMessageDownloading(data?.message, data?.progress); } }, ); } if (onDownloadingMediaMessageCanceled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'DownloadMediaMessage:onDownloadingMediaMessageCanceled', (data: any) => { if (data?.eventId === eventId) { onDownloadingMediaMessageCanceled && onDownloadingMediaMessageCanceled(data?.message); eventEmitter.remove(); if (onMediaMessageDownloadingEmitter) { onMediaMessageDownloadingEmitter.remove(); } } }, ); } if (onMediaMessageDownloaded) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'DownloadMediaMessage:onMediaMessageDownloaded', (data: any) => { if (data?.eventId === eventId) { onMediaMessageDownloaded && onMediaMessageDownloaded(data?.code, data?.message); eventEmitter.remove(); if (onMediaMessageDownloadingEmitter) { onMediaMessageDownloadingEmitter.remove(); } } }, ); } } logger.logObject('downloadMediaMessage', { message, listener, eventId }); return RCReactNativeIM.downloadMediaMessage(message, eventId); } /** * [ZH] * --- * 取消下载媒体消息 * @param message 需要取消下载的媒体消息实体 * @param callback 取消下载媒体消息的事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Cancel Media Message Download * @param message The media message entity for which the download needs to be * canceled. * @param callback The event callback for canceling the media message download. * The SDK supports callback-based notifications starting from * version 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and are expected to be removed * in version 6.x. If the callback parameter is provided, only * the callback will be triggered. * @return The status code for the current operation. 0 indicates a successful * call, and the specific result needs to be handled by the interface * callback. Non-zero values indicate that the current operation failed, * and no callback will be triggered. Refer to the error codes for * detailed error information. * --- */ cancelDownloadingMediaMessage( message: RCIMIWMediaMessage, callback?: IRCIMIWCancelDownloadingMediaMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onCancelDownloadingMediaMessageCalled } = callback; if (onCancelDownloadingMediaMessageCalled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'CancelDownloadingMediaMessage:onCancelDownloadingMediaMessageCalled', (data: any) => { if (data?.eventId === eventId) { onCancelDownloadingMediaMessageCalled && onCancelDownloadingMediaMessageCalled(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('cancelDownloadingMediaMessage', { message, callback, eventId }); return RCReactNativeIM.cancelDownloadingMediaMessage(message, eventId); } /** * [ZH] * --- * 获取某个会话 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 * @param callback 获取会话事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve a Conversation * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param callback Callback for retrieving the conversation. SDK supports * callback method from version 5.3.1. Other callback methods * for this interface are deprecated starting from version * 5.4.0 and will be removed in version 6.x. If the callback * parameter is provided, only the callback method will be * triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be handled in the interface * callback. Non-zero values indicate a failure in the current * operation, and no callback will be triggered. Refer to the error * codes for detailed error information. * --- */ getConversation( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetConversationCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetConversation:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetConversation:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getConversation', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getConversation(type, targetId, channelId, eventId); } /** * [ZH] * --- * 获取某些会话 * @param conversationTypes 会话类型 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 * @param startTime 时间戳(毫秒),获取小于此时间戳的会话,传 0 为查询最新数据 * @param count 查询的数量, 0 < count ≤ 50 * @param callback 获取会话列表事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve Certain Conversations * @param conversationTypes Specifies the conversation types. * @param channelId Indicates the channel ID, which is only supported * for ultra groups. For other conversation types, pass * null. * @param startTime Represents the timestamp (in milliseconds) for * retrieving conversations before this time. Pass 0 to * query the latest data. * @param count Specifies the number of conversations to retrieve, * where 0 < count ≤ 50. * @param callback Indicates the callback for retrieving the * conversation list. The SDK supports callback-based * retrieval starting from version 5.3.1. Other * callback methods for this interface were deprecated * in version 5.4.0 and are expected to be removed in * version 6.x. If the callback parameter is provided, * only the callback method will be triggered. * @return Returns the status code for the current operation. A value of 0 * indicates a successful call, and specific results need to be handled * through the interface callback. A non-zero value indicates that the * current operation failed, and no interface callback will be * triggered. Refer to the error codes for detailed error information. * --- */ getConversations( conversationTypes: Array, channelId: string, startTime: number, count: number, callback?: IRCIMIWGetConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversations:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetConversations:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getConversations', { conversationTypes, channelId, startTime, count, callback, eventId }); return RCReactNativeIM.getConversations(conversationTypes, channelId, startTime, count, eventId); } /** * [ZH] * --- * 获取某些会话,可设置是否优先置顶 * @param conversationTypes 会话类型 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 * @param startTime 时间戳(毫秒),获取小于此时间戳的会话,传 0 为查询最新数据 * @param count 查询的数量, 0 < count <= 50 * @param topPriority 是否优先置顶,true: 优先置顶,false: 不优先置顶 * @param callback 获取会话列表事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get conversations with optional pin priority * @param conversationTypes Conversation type * @param channelId Channel ID (ultra group only), set null for other * types * @param startTime Timestamp in ms (0 for latest data) * @param count Number to query (0 < count ≤ 50) * @param topPriority Pin priority: true/false * @param callback Callback for conversation list * @return Operation status code (0 = success, triggers callback; non-zero = * failure, no callback) * --- */ getConversationsWithPriority( conversationTypes: Array, channelId: string, startTime: number, count: number, topPriority: boolean, callback?: IRCIMIWGetConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsWithPriority:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsWithPriority:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationsWithPriority', { conversationTypes, channelId, startTime, count, topPriority, callback, eventId, }); return RCReactNativeIM.getConversationsWithPriority( conversationTypes, channelId, startTime, count, topPriority, eventId, ); } /** * [ZH] * --- * 获取指定类型的含有未读消息的会话列表 * @param conversationTypes 支持单聊、群聊、系统会话 * @param callback 获取会话列表事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the conversation list with unread messages of the specified * type. * @param conversationTypes Supported conversation types include one-to-one * chat, group chat, and system conversation. * @param callback Callback function for retrieving the conversation * list. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be obtained through the callback. * Non-zero values indicate a failed operation, and the callback will * not be triggered. Refer to the error codes for detailed error * information. * --- */ getUnreadConversations( conversationTypes: Array, callback?: IRCIMIWGetUnreadConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadConversations:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadConversations:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadConversations', { conversationTypes, callback, eventId }); return RCReactNativeIM.getUnreadConversations(conversationTypes, eventId); } /** * [ZH] * --- * 从服务器拉取会话列表 * @param callback 操作回调 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调 * --- * [EN] * --- * Fetch remote conversation list from server * @param callback Operation callback * @return Status code of the current operation. 0 indicates success, and the * specific result needs to be handled in the callback. Non-zero * values indicate failure and no callback will be triggered. * --- */ getRemoteConversationList(callback?: IRCIMIWOperationCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetRemoteConversationList:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetRemoteConversationList:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getRemoteConversationList', { callback, eventId }); return RCReactNativeIM.getRemoteConversationList(eventId); } /** * [ZH] * --- * 移除某个会话,可设置是否删除远端会话 * @param type 会话类型 * @param targetId 会话 ID * @param deleteRemote 是否删除远端会话 * @param callback 移除会话事件回调。如果传入了 callback 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove a conversation with optional remote delete * @param type Conversation type * @param targetId Conversation ID * @param deleteRemote Whether to delete remote conversation * @param callback Callback triggered when the conversation is removed. If * callback is provided, only the callback will be * triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be handled in the callback. * Non-zero values indicate that the current operation failed and no * callback will be triggered. Refer to the error codes for detailed * error information. * --- */ removeConversationWithDeleteRemote( type: RCIMIWConversationType, targetId: string, deleteRemote: boolean, callback?: IRCIMIWRemoveConversationCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationRemoved } = callback; if (onConversationRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveConversationWithDeleteRemote:onConversationRemoved', (data: any) => { if (data?.eventId === eventId) { onConversationRemoved && onConversationRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeConversationWithDeleteRemote', { type, targetId, deleteRemote, callback, eventId }); return RCReactNativeIM.removeConversationWithDeleteRemote(type, targetId, deleteRemote, eventId); } /** * [ZH] * --- * 移除某个会话 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可 * @param callback 移除会话事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove a Conversation * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types * @param callback Callback for the conversation removal event. SDK supports * callback method starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback method * will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be implemented in the interface * callback. Non-zero values indicate that the current operation failed * and the interface callback will not be triggered. Refer to the error * codes for detailed error information. * --- */ removeConversation( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWRemoveConversationCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationRemoved } = callback; if (onConversationRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveConversation:onConversationRemoved', (data: any) => { if (data?.eventId === eventId) { onConversationRemoved && onConversationRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeConversation', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.removeConversation(type, targetId, channelId, eventId); } /** * [ZH] * --- * 根据会话类型移除会话 * @param conversationTypes 会话类型集合 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 移除会话列表事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove conversations based on conversation type * @param conversationTypes A collection of conversation types * @param channelId Channel ID, only supported for ultra groups. Pass * null for other conversation types. * @param callback Callback for the conversation removal event. SDK * supports callback method from version 5.3.1. Other * callback methods for this interface are deprecated * starting from version 5.4.0 and will be removed in * version 6.x. If the callback parameter is provided, * only the callback method will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be handled in the interface * callback. Non-zero values indicate a failure in the current * operation, and no callback will be triggered. Refer to the error * codes for detailed error information. * --- */ removeConversations( conversationTypes: Array, channelId: string, callback?: IRCIMIWRemoveConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onConversationsRemoved } = callback; if (onConversationsRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveConversations:onConversationsRemoved', (data: any) => { if (data?.eventId === eventId) { onConversationsRemoved && onConversationsRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeConversations', { conversationTypes, channelId, callback, eventId }); return RCReactNativeIM.removeConversations(conversationTypes, channelId, eventId); } /** * [ZH] * --- * 获取某个会话的未读数 * 注:不支持聊天室! * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 获取会话未读数事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the unread count of a conversation * Note: Not supported for chatrooms! * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param callback Callback for retrieving the unread count of the * conversation. SDK supports callback-based retrieval starting * from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented via the * callback. Non-zero values indicate that the current operation failed, * and no callback will be triggered. Refer to the error codes for * detailed error information. * --- */ getUnreadCount( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetUnreadCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetUnreadCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetUnreadCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getUnreadCount', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getUnreadCount(type, targetId, channelId, eventId); } /** * [ZH] * --- * 获取所有未读数 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 获取所有未读数事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get Total Unread Count * @param channelId Channel ID, supported only for ultra groups. For other * conversation types, pass null. * @param callback Callback for the total unread count event. The SDK supports * callback-based handling starting from version 5.3.1. Other * callback methods for this interface were deprecated in * version 5.4.0 and are expected to be removed in the 6.x * version. If the callback parameter is provided, only the * callback will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be handled in the callback. Non-zero * values indicate a failed operation, and no callback will be * triggered. Refer to the error codes for detailed error information. * --- */ getTotalUnreadCount(channelId: string, callback?: IRCIMIWGetTotalUnreadCountCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTotalUnreadCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTotalUnreadCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getTotalUnreadCount', { channelId, callback, eventId }); return RCReactNativeIM.getTotalUnreadCount(channelId, eventId); } /** * [ZH] * --- * 获取会话中未读的 @ 消息数量。 * 注:不支持聊天室! * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 获取会话中未读的 @ 消息数量事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the count of unread @ messages in a conversation. * Note: This feature is not supported in chatrooms! * @param type Specifies the conversation type. * @param targetId Specifies the conversation ID. * @param channelId Specifies the channel ID. This is only supported for ultra * groups. For other conversation types, pass `null`. * @param callback Callback triggered when the count of unread @ messages is * retrieved. The SDK has supported callback mode since version * 5.3.1. Other callback methods for this interface were * deprecated in version 5.4.0 and are expected to be removed * in version 6.x. If the `callback` parameter is provided, * only the callback method will be triggered. * @return The status code of the current operation. `0` indicates a successful * call, and the specific result needs to be implemented in the * callback. A non-zero value indicates that the operation failed, and * the callback will not be triggered. Refer to the error codes for * detailed error information. * --- */ getUnreadMentionedCount( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetUnreadMentionedCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadMentionedCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadMentionedCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadMentionedCount', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getUnreadMentionedCount(type, targetId, channelId, eventId); } /** * [ZH] * --- * 获取当前用户加入的所有超级群会话的未读消息数的总和。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the total count of unread messages from all ultra group * conversations the current user has joined. * @param callback Event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface were deprecated in version 5.4.0 and are expected * to be removed in version 6.x. If a callback parameter is * provided, only the callback will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be obtained through * the interface callback. Non-zero values indicate that the current * interface call failed, and no callback will be triggered. Refer to * the error codes for detailed error information. * --- */ getUltraGroupAllUnreadCount(callback?: IRCIMIWGetUltraGroupAllUnreadCountCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupAllUnreadCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupAllUnreadCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupAllUnreadCount', { callback, eventId }); return RCReactNativeIM.getUltraGroupAllUnreadCount(eventId); } /** * [ZH] * --- * 获取当前用户加入的所有超级群会话中的未读 @ 消息数的总和。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the total count of unread @ mentions across all ultra group * conversations the current user has joined. * @param callback Event callback. SDK supports callback-based events starting * from version 5.3.1. Other callback methods for this interface * were deprecated in version 5.4.0 and are expected to be * removed in version 6.x. If the callback parameter is * provided, only the callback event will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and specific results need to be handled through the * interface callback. Non-zero values indicate that the current * interface call operation failed, and no interface callback will be * triggered. Refer to the error codes for detailed error information. * --- */ getUltraGroupAllUnreadMentionedCount( callback?: IRCIMIWGetUltraGroupAllUnreadMentionedCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupAllUnreadMentionedCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupAllUnreadMentionedCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupAllUnreadMentionedCount', { callback, eventId }); return RCReactNativeIM.getUltraGroupAllUnreadMentionedCount(eventId); } /** * [ZH] * --- * 获取指定会话的未读消息数 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the unread message count for a specified conversation * @param targetId Conversation ID * @param callback Event callback. The SDK supports callback-style responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback method will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. A non-zero value indicates that the current * operation failed, and no callback will be triggered. Refer to the * error codes for detailed error information. * --- */ getUltraGroupUnreadCount(targetId: string, callback?: IRCIMIWGetUltraGroupUnreadCountCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupUnreadCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupUnreadCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupUnreadCount', { targetId, callback, eventId }); return RCReactNativeIM.getUltraGroupUnreadCount(targetId, eventId); } /** * [ZH] * --- * 获取超级群会话中被 @ 的消息数 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the count of mentioned messages in an ultra group * conversation * @param targetId The conversation ID * @param callback The event callback. SDK supports callback-style events * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If a callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and specific results need to be handled via the interface * callback. Non-zero values indicate that the current operation failed, * and no callback will be triggered. Refer to the error codes for * detailed error information. * --- */ getUltraGroupUnreadMentionedCount( targetId: string, callback?: IRCIMIWGetUltraGroupUnreadMentionedCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupUnreadMentionedCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupUnreadMentionedCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupUnreadMentionedCount', { targetId, callback, eventId }); return RCReactNativeIM.getUltraGroupUnreadMentionedCount(targetId, eventId); } /** * [ZH] * --- * 根据会话类型加载未读数 * 注:不支持聊天室! * @param conversationTypes 会话类型集合 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param contain 是否包含免打扰消息的未读消息数。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Load unread count based on conversation type * Note: Chatrooms are not supported! * @param conversationTypes Specifies the collection of conversation types. * @param channelId Specifies the channel ID, which is only supported * for ultra groups. For other conversation types, pass * null. * @param contain Indicates whether to include unread messages from * muted conversations. * @param callback Specifies the event callback. The SDK supports * callback mode starting from version 5.3.1. Other * callback methods for this interface are deprecated * as of version 5.4.0 and are expected to be removed * in version 6.x. If the callback parameter is * provided, only the callback method will be * triggered. * @return Specifies the status code of the current operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero indicates that the current operation * failed, and the interface callback will not be triggered. Refer to * the error codes for detailed error information. * --- */ getUnreadCountByConversationTypes( conversationTypes: Array, channelId: string, contain: boolean, callback?: IRCIMIWGetUnreadCountByConversationTypesCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByConversationTypes:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByConversationTypes:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadCountByConversationTypes', { conversationTypes, channelId, contain, callback, eventId, }); return RCReactNativeIM.getUnreadCountByConversationTypes(conversationTypes, channelId, contain, eventId); } /** * [ZH] * --- * 根据会话的免打扰级别加载未读数 * @param conversationTypes 会话类型列表 * @param levels 免打扰级别列表 * @param callback 获取会话未读消息数回调 * @return 当次接口操作的状态码。0 代表调用成功 具体结果通过接口 callback 回调,非 0 * 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Load unread count by conversation's DND level * @param conversationTypes List of conversation types * @param levels List of DND levels * @param callback Callback for unread message count * @return Status code: 0 means success (results via callback), non-zero means * failure (no callback triggered). See error codes for details * --- */ getUnreadCountByLevels( conversationTypes: Array, levels: Array, callback?: IRCIMIWGetUnreadCountByLevelsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } if (levels) { levels = levels.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByLevels:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByLevels:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadCountByLevels', { conversationTypes, levels, callback, eventId }); return RCReactNativeIM.getUnreadCountByLevels(conversationTypes, levels, eventId); } /** * [ZH] * --- * 清除某个会话中的未读消息数。 * 注:不支持聊天室! * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp 该会话已阅读的最后一条消息的发送时间戳,清除所有传入当前最新时间戳 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Clear the unread message count for a specific conversation. * Note: Not supported for chatrooms! * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param timestamp The timestamp of the last read message in the conversation. * Pass the latest timestamp to clear all. * @param callback Event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and will be * removed in the 6.x version. If the callback parameter is * provided, only the callback method will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled by the callback. * Non-zero values indicate the operation failed, and no callback will * be triggered. Refer to the error codes for details. * --- */ clearUnreadCount( type: RCIMIWConversationType, targetId: string, channelId: string, timestamp: number, callback?: IRCIMIWClearUnreadCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUnreadCountCleared } = callback; if (onUnreadCountCleared) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearUnreadCount:onUnreadCountCleared', (data: any) => { if (data?.eventId === eventId) { onUnreadCountCleared && onUnreadCountCleared(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearUnreadCount', { type, targetId, channelId, timestamp, callback, eventId }); return RCReactNativeIM.clearUnreadCount(type, targetId, channelId, timestamp, eventId); } /** * [ZH] * --- * 保存会话草稿信息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param draft 草稿的文字内容。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Save conversation draft information. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param draft The text content of the draft. * @param callback Event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * operation failed, and no interface callback will be triggered. For * detailed error information, refer to the error codes. * --- */ saveDraftMessage( type: RCIMIWConversationType, targetId: string, channelId: string, draft: string, callback?: IRCIMIWSaveDraftMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onDraftMessageSaved } = callback; if (onDraftMessageSaved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SaveDraftMessage:onDraftMessageSaved', (data: any) => { if (data?.eventId === eventId) { onDraftMessageSaved && onDraftMessageSaved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('saveDraftMessage', { type, targetId, channelId, draft, callback, eventId }); return RCReactNativeIM.saveDraftMessage(type, targetId, channelId, draft, eventId); } /** * [ZH] * --- * 获取会话中的草稿信息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve draft information from a conversation. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, supported only for ultra groups. Pass null for * other conversation types. * @param callback Event callback. The SDK supports callback-based event * handling starting from version 5.3.1. Other callback methods * for this interface are deprecated as of version 5.4.0 and * are expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate a failed operation, and no * callback will be triggered. Refer to the error codes for detailed * error information. * --- */ getDraftMessage( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetDraftMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetDraftMessage:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetDraftMessage:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getDraftMessage', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getDraftMessage(type, targetId, channelId, eventId); } /** * [ZH] * --- * 删除指定会话中的草稿信息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Deletes draft information from the specified conversation. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param callback Event callback. SDK supports callback mode from version * 5.3.1. Other callback methods for this interface are * deprecated starting from version 5.4.0 and are expected to * be removed in version 6.x. If the callback parameter is * provided, only the callback method will be triggered. * @return Status code of the current operation. 0 indicates success. Specific * results need to be implemented via the callback interface. Non-zero * values indicate that the current operation failed and the callback * will not be triggered. Refer to the error codes for detailed error * information. * --- */ clearDraftMessage( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWClearDraftMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onDraftMessageCleared } = callback; if (onDraftMessageCleared) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearDraftMessage:onDraftMessageCleared', (data: any) => { if (data?.eventId === eventId) { onDraftMessageCleared && onDraftMessageCleared(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearDraftMessage', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.clearDraftMessage(type, targetId, channelId, eventId); } /** * [ZH] * --- * 获取免打扰的会话列表。 * @param conversationTypes 会话类型集合 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the list of conversations with Do Not Disturb enabled. * @param conversationTypes A collection of conversation types. * @param channelId The channel ID, only supported for ultra groups. * Pass null for other conversation types. * @param callback The event callback. The SDK has supported * callback-based responses since version 5.3.1. Other * callback methods for this interface have been * deprecated since version 5.4.0 and are expected to * be removed in version 6.x. If the callback parameter * is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no callback will be triggered. Refer to the error codes for * detailed error information. * --- */ getBlockedConversations( conversationTypes: Array, channelId: string, callback?: IRCIMIWGetBlockedConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBlockedConversations:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBlockedConversations:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getBlockedConversations', { conversationTypes, channelId, callback, eventId }); return RCReactNativeIM.getBlockedConversations(conversationTypes, channelId, eventId); } /** * [ZH] * --- * 设置会话的置顶状态。若会话不存在,调用此方法 SDK 自动创建会话并置顶。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param top 是否置顶 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Sets the pinned status of a conversation. If the conversation does * not exist, calling this method will automatically create and pin * the conversation. * @param type Specifies the conversation type. * @param targetId Specifies the conversation ID. * @param channelId Specifies the channel ID, which is only supported for ultra * groups. For other conversation types, pass null. * @param top Indicates whether to pin the conversation. * @param callback Specifies the event callback. The SDK supports * callback-style callbacks starting from version 5.3.1. Other * callback methods for this interface were deprecated in * version 5.4.0 and are expected to be removed in version 6.x. * If the callback parameter is provided, only the callback * will be triggered. * @return Returns the status code of the current operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * --- */ changeConversationTopStatus( type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean, callback?: IRCIMIWChangeConversationTopStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationTopStatusChanged } = callback; if (onConversationTopStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeConversationTopStatus:onConversationTopStatusChanged', (data: any) => { if (data?.eventId === eventId) { onConversationTopStatusChanged && onConversationTopStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeConversationTopStatus', { type, targetId, channelId, top, callback, eventId }); return RCReactNativeIM.changeConversationTopStatus(type, targetId, channelId, top, eventId); } /** * [ZH] * --- * 设置会话的置顶状态。若会话不存在,调用此方法 SDK 自动创建会话并置顶。 * @param type conversation type * @param targetId conversation ID * @param channelId 频道 ID,仅支持ultra group使用,其他conversation type传 null * 即可。 * @param top 是否置顶 * @param updateOperationTime 是否更新操作事件,默认不更新,如果需要更新请传 true * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Pin or unpin a conversation. SDK auto-creates missing * conversations. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID (ultra group only, set null for others) * @param top Pin status * @param updateOperationTime Update operation timestamp (default: false) * @param callback Event callback (supported since v5.3.1). Other * callback methods deprecated in v5.4.0 and will be * removed in v6.x. Callback param overrides all * other callbacks. * @return Operation status code (0 = success, triggers callback; non-zero = * failure, no callback) * --- */ changeConversationTopStatusWithUpdateTme( type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean, updateOperationTime: boolean, callback?: IRCIMIWChangeConversationTopStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationTopStatusChanged } = callback; if (onConversationTopStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeConversationTopStatusWithUpdateTme:onConversationTopStatusChanged', (data: any) => { if (data?.eventId === eventId) { onConversationTopStatusChanged && onConversationTopStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeConversationTopStatusWithUpdateTme', { type, targetId, channelId, top, updateOperationTime, callback, eventId, }); return RCReactNativeIM.changeConversationTopStatusWithUpdateTme( type, targetId, channelId, top, updateOperationTime, eventId, ); } /** * [ZH] * --- * 获取会话的置顶状态 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the pinned status of a conversation * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param callback Event callback. SDK supports callback method from version * 5.3.1. Other callback methods for this interface are * deprecated starting from version 5.4.0 and are expected to * be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return Status code of the current interface operation. 0 indicates a * successful call, and specific results need to be implemented through * the interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. Refer to the error codes for detailed errors. * --- */ getConversationTopStatus( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetConversationTopStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTopStatus:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTopStatus:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationTopStatus', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getConversationTopStatus(type, targetId, channelId, eventId); } /** * [ZH] * --- * 同步会话阅读状态。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp 会话中已读的最后一条消息的发送时间戳 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Synchronize conversation read status. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param timestamp Timestamp of the last read message in the conversation * @param callback Event callback. SDK supports callback method starting from * version 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and are expected to be * removed in version 6.x. If the callback parameter is * provided, only the callback method will be triggered. * @return Status code of the current operation. 0 indicates successful * invocation, and specific results need to be handled via the interface * callback. Non-zero values indicate failure of the current operation, * and no callback will be triggered. Refer to the error codes for * detailed error information. * --- */ syncConversationReadStatus( type: RCIMIWConversationType, targetId: string, channelId: string, timestamp: number, callback?: IRCIMIWSyncConversationReadStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationReadStatusSynced } = callback; if (onConversationReadStatusSynced) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SyncConversationReadStatus:onConversationReadStatusSynced', (data: any) => { if (data?.eventId === eventId) { onConversationReadStatusSynced && onConversationReadStatusSynced(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('syncConversationReadStatus', { type, targetId, channelId, timestamp, callback, eventId }); return RCReactNativeIM.syncConversationReadStatus(type, targetId, channelId, timestamp, eventId); } /** * [ZH] * --- * 向会话中发送正在输入的状态,目前只支持单聊。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param currentType 当前的状态 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send a typing status to the conversation. Currently, this feature is * only supported in one-to-one chats. * @param type Specifies the conversation type * @param targetId Specifies the conversation ID * @param channelId Specifies the channel ID, which is only supported for * ultra groups. For other conversation types, pass null. * @param currentType Specifies the current status * @return Returns the status code of the operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * callback interface. A non-zero value indicates that the call failed * and will not trigger the callback. Refer to the error codes for * detailed error information. * --- */ sendTypingStatus( type: RCIMIWConversationType, targetId: string, channelId: string, currentType: string, ): Promise { logger.logObject('sendTypingStatus', { type, targetId, channelId, currentType }); return RCReactNativeIM.sendTypingStatus(type, targetId, channelId, currentType); } /** * [ZH] * --- * 加载历史消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param sentTime 当前消息时间戳 * @param order 获取消息的方向。BEFORE:获取 sentTime 之前的消息 (时间递减),AFTER:获取 sentTime * 之后的消息 (时间递增) * @param policy 消息的加载策略。LOCAL:只加载本地,REMOTE:只加载远端,LOCAL_REMOTE:本地远端都加载 * @param count 获取的消息数量,0 < count ≤ 20 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Load Historical Messages * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param sentTime Timestamp of the current message * @param order Direction to fetch messages. BEFORE: Fetch messages before * sentTime (in descending order). AFTER: Fetch messages after * sentTime (in ascending order). * @param policy Message loading strategy. LOCAL: Load only local messages. * REMOTE: Load only remote messages. LOCAL_REMOTE: Load both * local and remote messages. * @param count Number of messages to fetch, where 0 < count ≤ 20 * @param callback Event callback. SDK supports callback starting from version * 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and will be removed in * version 6.x. If the callback parameter is provided, only the * callback will be triggered. * @return Status code of the current operation. 0 indicates success. Specific * results need to be implemented via the interface callback. Non-zero * indicates the current operation failed, and no interface callback * will be triggered. Refer to the error codes for detailed error * information. * --- */ getMessages( type: RCIMIWConversationType, targetId: string, channelId: string, sentTime: number, order: RCIMIWTimeOrder, policy: RCIMIWMessageOperationPolicy, count: number, callback?: IRCIMIWGetMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessages:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessages:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getMessages', { type, targetId, channelId, sentTime, order, policy, count, callback, eventId, }); return RCReactNativeIM.getMessages(type, targetId, channelId, sentTime, order, policy, count, eventId); } /** * [ZH] * --- * 根据消息 id 获取消息体(本地数据库索引唯一值)。 * @param messageId 消息的 messageId,可在消息对象中获取 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the message body based on the message ID (unique value in * the local database index). * @param messageId The messageId of the message, which can be obtained from the * message object. * @param callback The event callback. The SDK supports callback-style * callbacks starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. For detailed errors, refer to the error codes. * --- */ getMessageById(messageId: number, callback?: IRCIMIWGetMessageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageById:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageById:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getMessageById', { messageId, callback, eventId }); return RCReactNativeIM.getMessageById(messageId, eventId); } /** * [ZH] * --- * 通过全局唯一 id 获取消息实体。 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the message entity by its globally unique ID. * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param callback The event callback. The SDK supports callback-style * callbacks starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current * interface call operation failed, and no interface callback will be * triggered. Refer to the error codes for detailed error information. * --- */ getMessageByUId(messageUId: string, callback?: IRCIMIWGetMessageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageByUId:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageByUId:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getMessageByUId', { messageUId, callback, eventId }); return RCReactNativeIM.getMessageByUId(messageUId, eventId); } /** * [ZH] * --- * 在会话中获取指定消息的前后指定数量的消息。返回的消息列表中会包含指定的消息。消息列表时间顺序从新到旧。 * @param type 会话类型。 * @param targetId 会话 ID。 * @param channelId 消息所属会话的业务标识。 * @param sentTime 指定消息的发送时间,不能为 0。单位:毫秒。 * @param beforeCount 指定消息的前部分消息数量。 * @param afterCount 指定消息的后部分消息数量。 * @param callback 获取结果回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果通过接口 callback 回调,非 0 * 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get messages around a specified one in conversation. The returned * list includes the target message, sorted from newest to oldest. * @param type Conversation type * @param targetId Conversation ID * @param channelId Business identifier for the conversation * @param sentTime Target message's timestamp (in milliseconds), can't be 0 * @param beforeCount Number of messages before the target * @param afterCount Number of messages after the target * @param callback Result callback * @return Status code: 0 means success (results via callback), non-zero means * failure (check error codes) * --- */ getMessagesAroundTime( type: RCIMIWConversationType, targetId: string, channelId: string, sentTime: number, beforeCount: number, afterCount: number, callback?: IRCIMIWGetMessagesAroundTimeCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetMessagesAroundTime:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetMessagesAroundTime:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getMessagesAroundTime', { type, targetId, channelId, sentTime, beforeCount, afterCount, callback, eventId, }); return RCReactNativeIM.getMessagesAroundTime( type, targetId, channelId, sentTime, beforeCount, afterCount, eventId, ); } /** * [ZH] * --- * 获取会话中指定类型的消息。 * @param type 会话类型。 * @param targetId 会话 ID。 * @param channelId 消息所属会话的业务标识。 * @param messageTypes 消息类型列表。 * @param sentTime 消息发送时间戳,0 表示最新的消息 * @param order 获取消息的方向。BEFORE:获取 sentTime 之前的消息 (时间递减),AFTER:获取 sentTime * 之后的消息 (时间递增) * @param count 获取的消息数量 * @param callback 获取结果回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果通过接口 callback 回调,非 0 * 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Fetch messages of specified types in conversation * @param type Conversation type * @param targetId Conversation ID * @param channelId Business identifier for the conversation * @param messageTypes List of message types * @param sentTime Message timestamp (0 for latest) * @param order Fetch direction: BEFORE for messages prior to sentTime * (descending), AFTER for messages after sentTime * (ascending) * @param count Number of messages to fetch * @param callback Result callback * @return Status code (0 means success—results via callback, non-zero means * failure—check error codes) * --- */ getLocalMessagesByMessageTypes( type: RCIMIWConversationType, targetId: string, channelId: string, messageTypes: Array, sentTime: number, order: RCIMIWTimeOrder, count: number, callback?: IRCIMIWGetMessagesCallback, ): Promise { if (messageTypes) { messageTypes = messageTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetLocalMessagesByMessageTypes:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetLocalMessagesByMessageTypes:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getLocalMessagesByMessageTypes', { type, targetId, channelId, messageTypes, sentTime, order, count, callback, eventId, }); return RCReactNativeIM.getLocalMessagesByMessageTypes( type, targetId, channelId, messageTypes, sentTime, order, count, eventId, ); } /** * [ZH] * --- * 获取第一条未读消息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the first unread message. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param callback Event callback. The SDK has supported callback-based * responses since version 5.3.1. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return Status code for the current operation. 0 indicates a successful call, * and the specific result needs to be handled in the callback. Non-zero * values indicate that the operation failed, and no callback will be * triggered. Refer to the error codes for detailed error information. * --- */ getFirstUnreadMessage( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetFirstUnreadMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetFirstUnreadMessage:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetFirstUnreadMessage:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getFirstUnreadMessage', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getFirstUnreadMessage(type, targetId, channelId, eventId); } /** * [ZH] * --- * 获取会话中未读的 @ 消息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Fetch unread @ messages in a conversation. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param callback Event callback. SDK supports callback-style responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return Status code for the current operation. 0 indicates a successful call, * and specific results need to be handled in the interface callback. * Non-zero values indicate that the current operation failed and will * not trigger the interface callback. Refer to the error codes for * detailed error information. * --- */ getUnreadMentionedMessages( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetUnreadMentionedMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadMentionedMessages:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadMentionedMessages:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadMentionedMessages', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getUnreadMentionedMessages(type, targetId, channelId, eventId); } /** * [ZH] * --- * 插入一条消息 * @param message 插入的消息 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Insert a Message * @param message The message to be inserted. * @param callback Event callback. The SDK has supported callback-based event * handling since version 5.3.1. Other callback methods for this * interface have been deprecated since version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ insertMessage(message: RCIMIWMessage, callback?: IRCIMIWInsertMessageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageInserted } = callback; if (onMessageInserted) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'InsertMessage:onMessageInserted', (data: any) => { if (data?.eventId === eventId) { onMessageInserted && onMessageInserted(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('insertMessage', { message, callback, eventId }); return RCReactNativeIM.insertMessage(message, eventId); } /** * [ZH] * --- * 插入多条消息,不支持超级群 * @param messages 插入的消息集合 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Insert multiple messages. Ultra groups are not supported. * @param messages The collection of messages to be inserted. * @param callback The event callback. Starting from version 5.3.1, the SDK * supports callback for event handling. Other callback methods * for this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled by implementing the * interface callback. A non-zero value indicates that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * --- */ insertMessages(messages: Array, callback?: IRCIMIWInsertMessagesCallback): Promise { if (messages) { messages = messages.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onMessagesInserted } = callback; if (onMessagesInserted) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'InsertMessages:onMessagesInserted', (data: any) => { if (data?.eventId === eventId) { onMessagesInserted && onMessagesInserted(data?.code, data?.messages); eventEmitter.remove(); } }, ); } } logger.logObject('insertMessages', { messages, callback, eventId }); return RCReactNativeIM.insertMessages(messages, eventId); } /** * [ZH] * --- * 清除消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp 清除消息截止时间戳,0 ≤ timestamp ≤ 当前会话最后一条消息的 sentTime, 0 * 清除所有消息,其他值清除小于等于 timestamp 的消息 * @param policy 清除的策略 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Clear Messages * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param timestamp Timestamp for clearing messages up to a certain time. 0 ≤ * timestamp ≤ sentTime of the last message in the current * conversation. 0 clears all messages, other values clear * messages with sentTime ≤ timestamp. * @param policy Clearing policy * @param callback Event callback. SDK supports callback mode starting from * version 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and will be removed in * version 6.x. If the callback parameter is provided, only the * callback will be triggered. * @return Status code of the current operation. 0 indicates a successful call. * Specific results need to be handled in the interface callback. * Non-zero indicates the current operation failed and no callback will * be triggered. Refer to the error code for details. * --- */ clearMessages( type: RCIMIWConversationType, targetId: string, channelId: string, timestamp: number, policy: RCIMIWMessageOperationPolicy, callback?: IRCIMIWClearMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessagesCleared } = callback; if (onMessagesCleared) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearMessages:onMessagesCleared', (data: any) => { if (data?.eventId === eventId) { onMessagesCleared && onMessagesCleared(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearMessages', { type, targetId, channelId, timestamp, policy, callback, eventId }); return RCReactNativeIM.clearMessages(type, targetId, channelId, timestamp, policy, eventId); } /** * [ZH] * --- * 删除本地消息 * @param messages 消息集合 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete Local Messages * @param messages The collection of messages to be deleted. * @param callback The event callback. Starting from version 5.3.1, the SDK * supports callback-based event handling. Other callback * methods for this interface were deprecated in version 5.4.0 * and are expected to be removed in the 6.x release. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. A non-zero value indicates that the current operation * failed, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ deleteLocalMessages( messages: Array, callback?: IRCIMIWDeleteLocalMessagesCallback, ): Promise { if (messages) { messages = messages.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onLocalMessagesDeleted } = callback; if (onLocalMessagesDeleted) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'DeleteLocalMessages:onLocalMessagesDeleted', (data: any) => { if (data?.eventId === eventId) { onLocalMessagesDeleted && onLocalMessagesDeleted(data?.code, data?.messages); eventEmitter.remove(); } }, ); } } logger.logObject('deleteLocalMessages', { messages, callback, eventId }); return RCReactNativeIM.deleteLocalMessages(messages, eventId); } /** * [ZH] * --- * 根据 messageId 批量删除本地消息 * @param messageIds 消息的 messageId 集合 * @param callback 事件回调 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete local messages in batch by messageId * @param messageIds Set of message IDs * @param callback Event callback * @return Status code: 0 means success (check callback for details), non-zero * means failure (no callback triggered). See error codes for details * --- */ deleteLocalMessageByIds( messageIds: Array, callback?: IRCIMIWDeleteLocalMessageByIdsCallback, ): Promise { if (messageIds) { messageIds = messageIds.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onCompleted } = callback; if (onCompleted) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'DeleteLocalMessageByIds:onCompleted', (data: any) => { if (data?.eventId === eventId) { onCompleted && onCompleted(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('deleteLocalMessageByIds', { messageIds, callback, eventId }); return RCReactNativeIM.deleteLocalMessageByIds(messageIds, eventId); } /** * [ZH] * --- * 删除消息 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param messages 消息集合 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete Messages * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param messages Message collection * @param callback Event callback. SDK supports callback mode starting from * version 5.3.1. Other callback methods for this interface are * deprecated in version 5.4.0 and are expected to be removed * in version 6.x. If the callback parameter is provided, only * the callback will be triggered. * @return Status code of the current operation. 0 indicates successful * invocation. Specific results need to be implemented through the * interface callback. Non-zero values indicate failure in the current * operation, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ deleteMessages( type: RCIMIWConversationType, targetId: string, channelId: string, messages: Array, callback?: IRCIMIWDeleteMessagesCallback, ): Promise { if (messages) { messages = messages.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onMessagesDeleted } = callback; if (onMessagesDeleted) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'DeleteMessages:onMessagesDeleted', (data: any) => { if (data?.eventId === eventId) { onMessagesDeleted && onMessagesDeleted(data?.code, data?.messages); eventEmitter.remove(); } }, ); } } logger.logObject('deleteMessages', { type, targetId, channelId, messages, callback, eventId }); return RCReactNativeIM.deleteMessages(type, targetId, channelId, messages, eventId); } /** * [ZH] * --- * 撤回消息 * @param message 需要被撤回的消息 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Recall Message * @param message The message to be recalled. * @param callback Event callback. The SDK has supported callback-style * callbacks since version 5.3.1. Other callback methods for * this interface have been deprecated since version 5.4.0 and * are expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current * interface call operation failed, and no interface callback will be * triggered. For detailed error information, refer to the error codes. * --- */ recallMessage(message: RCIMIWMessage, callback?: IRCIMIWRecallMessageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageRecalled } = callback; if (onMessageRecalled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RecallMessage:onMessageRecalled', (data: any) => { if (data?.eventId === eventId) { onMessageRecalled && onMessageRecalled(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('recallMessage', { message, callback, eventId }); return RCReactNativeIM.recallMessage(message, eventId); } /** * [ZH] * --- * 发送某个会话中的消息阅读回执 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp 该会话中已读的最后一条消息的发送时间戳 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send a read receipt for messages in a specific conversation. * @param targetId The conversation ID. * @param channelId The channel ID, only supported for ultra groups. Pass `null` * for other conversation types. * @param timestamp The timestamp of the last read message in the conversation. * @param callback The event callback. SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the `callback` * parameter is provided, only the callback method will be * triggered. * @return The status code of the current operation. `0` indicates a successful * call, and the specific result needs to be implemented via the * interface callback. Non-zero values indicate that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * --- */ sendPrivateReadReceiptMessage( targetId: string, channelId: string, timestamp: number, callback?: IRCIMIWSendPrivateReadReceiptMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onPrivateReadReceiptMessageSent } = callback; if (onPrivateReadReceiptMessageSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendPrivateReadReceiptMessage:onPrivateReadReceiptMessageSent', (data: any) => { if (data?.eventId === eventId) { onPrivateReadReceiptMessageSent && onPrivateReadReceiptMessageSent(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('sendPrivateReadReceiptMessage', { targetId, channelId, timestamp, callback, eventId }); return RCReactNativeIM.sendPrivateReadReceiptMessage(targetId, channelId, timestamp, eventId); } /** * [ZH] * --- * 发起群聊消息已读回执请求 * @param message 需要请求已读回执的消息 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send Group Message Read Receipt Request * @param message The message for which the read receipt is requested. * @param callback Event callback. Starting from SDK version 5.3.1, callback * mode is supported. Other callback methods for this interface * are deprecated as of version 5.4.0 and are expected to be * removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled through the * interface callback. A non-zero value indicates that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * --- */ sendGroupReadReceiptRequest( message: RCIMIWMessage, callback?: IRCIMIWSendGroupReadReceiptRequestCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onGroupReadReceiptRequestSent } = callback; if (onGroupReadReceiptRequestSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendGroupReadReceiptRequest:onGroupReadReceiptRequestSent', (data: any) => { if (data?.eventId === eventId) { onGroupReadReceiptRequestSent && onGroupReadReceiptRequestSent(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('sendGroupReadReceiptRequest', { message, callback, eventId }); return RCReactNativeIM.sendGroupReadReceiptRequest(message, eventId); } /** * [ZH] * --- * 发送群聊已读回执 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param messages 会话中需要发送已读回执的消息列表 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send Group Read Receipt * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param messages List of messages in the conversation for which read receipts * need to be sent * @param callback Event callback. SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result requires implementing the interface callback. * Non-zero values indicate that the current operation failed, and no * callback will be triggered. Refer to the error codes for detailed * error information. * --- */ sendGroupReadReceiptResponse( targetId: string, channelId: string, messages: Array, callback?: IRCIMIWSendGroupReadReceiptResponseCallback, ): Promise { if (messages) { messages = messages.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onGroupReadReceiptResponseSent } = callback; if (onGroupReadReceiptResponseSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendGroupReadReceiptResponse:onGroupReadReceiptResponseSent', (data: any) => { if (data?.eventId === eventId) { onGroupReadReceiptResponseSent && onGroupReadReceiptResponseSent(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('sendGroupReadReceiptResponse', { targetId, channelId, messages, callback, eventId }); return RCReactNativeIM.sendGroupReadReceiptResponse(targetId, channelId, messages, eventId); } /** * [ZH] * --- * 更新消息扩展信息 * 每条消息携带扩展信息键值对最大值 300个,单次设置扩展信息键值对最大值 20个 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值 * @param expansion 要更新的消息扩展信息键值对,类型是 HashMap;Key 支持大小写英文字母、数字、部分特殊符号 + = - _ * 的组合方式,不支持汉字。Value 可以输入空格 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Update Message Extension Information * Each message can carry a maximum of 300 key-value pairs of * extension information, and a single update can set a maximum of 20 * key-value pairs. * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param expansion The key-value pairs of message extension information to be * updated, of type HashMap. The Key supports a combination of * uppercase and lowercase English letters, numbers, and some * special symbols + = - _. Chinese characters are not * supported. The Value can include spaces. * @param callback The event callback. The SDK supports callback-style * callbacks starting from version 5.3.1. Other callback * methods for this interface are deprecated starting from * version 5.4.0 and are expected to be removed in version * 6.x. If the callback parameter is provided, only the * callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current operation * failed, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ updateMessageExpansion( messageUId: string, expansion: Map, callback?: IRCIMIWUpdateMessageExpansionCallback, ): Promise { let _expansion: any = Object.fromEntries(expansion); const eventId = Math.random().toString(); if (callback) { const { onMessageExpansionUpdated } = callback; if (onMessageExpansionUpdated) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'UpdateMessageExpansion:onMessageExpansionUpdated', (data: any) => { if (data?.eventId === eventId) { onMessageExpansionUpdated && onMessageExpansionUpdated(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('updateMessageExpansion', { messageUId, expansion, callback, eventId }); return RCReactNativeIM.updateMessageExpansion(messageUId, _expansion, eventId); } /** * [ZH] * --- * 删除消息扩展信息中特定的键值对 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值 * @param keys 消息扩展信息中待删除的 key 的列表,类型是 ArrayList * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete specific key-value pairs from message extension information * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param keys The list of keys to be deleted from the message extension * information. The type is ArrayList. * @param callback Event callback. The SDK supports callback-style responses * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * interface callback. Non-zero indicates that the current interface * call failed and will not trigger the interface callback. Refer to the * error codes for detailed error information. * --- */ removeMessageExpansionForKeys( messageUId: string, keys: Array, callback?: IRCIMIWRemoveMessageExpansionForKeysCallback, ): Promise { if (keys) { keys = keys.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onMessageExpansionForKeysRemoved } = callback; if (onMessageExpansionForKeysRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveMessageExpansionForKeys:onMessageExpansionForKeysRemoved', (data: any) => { if (data?.eventId === eventId) { onMessageExpansionForKeysRemoved && onMessageExpansionForKeysRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeMessageExpansionForKeys', { messageUId, keys, callback, eventId }); return RCReactNativeIM.removeMessageExpansionForKeys(messageUId, keys, eventId); } /** * [ZH] * --- * 设置消息发送状态。 * @param messageId 消息的 messageId,可在消息对象中获取 * @param sentStatus 要修改的状态 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the message sending status. * @param messageId The messageId of the message, which can be obtained from * the message object. * @param sentStatus The status to be modified. * @param callback Event callback. The SDK supports callback-based * notification starting from version 5.3.1. Other callback * methods for this interface are deprecated in version 5.4.0 * and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * operation failed, and no interface callback will be triggered. Refer * to the error codes for detailed error information. * --- */ changeMessageSentStatus( messageId: number, sentStatus: RCIMIWSentStatus, callback?: IRCIMIWChangeMessageSentStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageSentStatusChanged } = callback; if (onMessageSentStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeMessageSentStatus:onMessageSentStatusChanged', (data: any) => { if (data?.eventId === eventId) { onMessageSentStatusChanged && onMessageSentStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeMessageSentStatus', { messageId, sentStatus, callback, eventId }); return RCReactNativeIM.changeMessageSentStatus(messageId, sentStatus, eventId); } /** * [ZH] * --- * 设置消息接收状态。 * @param messageId 消息的 messageId,可在消息对象中获取 * @param receivedStatus 要修改的状态 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the message received status. * @param messageId The messageId of the message, which can be obtained * from the message object. * @param receivedStatus The status to be modified. * @param callback Event callback. The SDK has supported callback-style * responses since version 5.3.1. Other callback methods * for this interface were deprecated in version 5.4.0 and * are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will * be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ changeMessageReceiveStatus( messageId: number, receivedStatus: RCIMIWReceivedStatus, callback?: IRCIMIWChangeMessageReceivedStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageReceiveStatusChanged } = callback; if (onMessageReceiveStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeMessageReceiveStatus:onMessageReceiveStatusChanged', (data: any) => { if (data?.eventId === eventId) { onMessageReceiveStatusChanged && onMessageReceiveStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeMessageReceiveStatus', { messageId, receivedStatus, callback, eventId }); return RCReactNativeIM.changeMessageReceiveStatus(messageId, receivedStatus, eventId); } /** * [ZH] * --- * 设置消息接收状态。 * @param messageId 消息的 messageId,可在消息对象中获取 * @param receivedStatusInfo 要修改的状态 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set message received status * @param messageId Message ID from Message Object * @param receivedStatusInfo Status to modify * @param callback Event callback. Supported since SDK 5.3.1. Other * callback methods deprecated in 5.4.0 and will be * removed in 6.x. If callback is provided, only * triggers callback response. * @return Operation status code. 0 means success (check callback for actual * result). Non-zero means failure (no callback triggered). See error * codes for details. * --- */ changeMessageReceiveStatusInfo( messageId: number, receivedStatusInfo: RCIMIWReceivedStatusInfo, callback?: IRCIMIWChangeMessageReceivedStatusInfoCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageReceiveStatusInfoChanged } = callback; if (onMessageReceiveStatusInfoChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeMessageReceiveStatusInfo:onMessageReceiveStatusInfoChanged', (data: any) => { if (data?.eventId === eventId) { onMessageReceiveStatusInfoChanged && onMessageReceiveStatusInfoChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeMessageReceiveStatusInfo', { messageId, receivedStatusInfo, callback, eventId }); return RCReactNativeIM.changeMessageReceiveStatusInfo(messageId, receivedStatusInfo, eventId); } /** * [ZH] * --- * 设置消息的附加信息,只能用于本地使用,无法同步到远端。 * @param messageId 消息的 messageId,可在消息对象中获取 * @param extra 附加信息 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set message extras for local use only (won't sync to server) * @param messageId Message ID from Message Object * @param extra Additional data * @param callback Event callback * @return Status code: 0 means success (check callback for details), non-zero * means failure (no callback triggered). See error codes for details * --- */ updateMessageLocalExtra( messageId: number, extra: string, callback?: IRCIMIWUpdateMessageLocalExtraCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onMessageLocalExtraUpdated } = callback; if (onMessageLocalExtraUpdated) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'UpdateMessageLocalExtra:onMessageLocalExtraUpdated', (data: any) => { if (data?.eventId === eventId) { onMessageLocalExtraUpdated && onMessageLocalExtraUpdated(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('updateMessageLocalExtra', { messageId, extra, callback, eventId }); return RCReactNativeIM.updateMessageLocalExtra(messageId, extra, eventId); } /** * [ZH] * --- * 加入聊天室。 * @param targetId 聊天室会话 ID * @param messageCount 进入聊天室拉取消息数目,-1 时不拉取任何消息,0 时拉取 10 条消息,最多只能拉取 50 * @param autoCreate 是否创建聊天室,TRUE 如果聊天室不存在,sdk 会创建聊天室并加入,如果已存在,则直接加入 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Join a chatroom. * @param targetId The chatroom conversation ID * @param messageCount The number of messages to fetch upon entering the * chatroom. -1 means no messages will be fetched, 0 means * fetching 10 messages, with a maximum of 50 messages * allowed. * @param autoCreate Whether to create the chatroom. If TRUE and the chatroom * does not exist, the SDK will create the chatroom and join * it. If the chatroom already exists, the SDK will directly * join it. * @param callback Event callback. The SDK supports callback-based events * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be * triggered. * @return The status code for the current operation. 0 indicates a successful * call, and the specific result needs to be handled by the interface * callback. Non-zero values indicate a failure in the current * operation, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ joinChatRoom( targetId: string, messageCount: number, autoCreate: boolean, callback?: IRCIMIWJoinChatRoomCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onChatRoomJoined } = callback; if (onChatRoomJoined) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'JoinChatRoom:onChatRoomJoined', (data: any) => { if (data?.eventId === eventId) { onChatRoomJoined && onChatRoomJoined(data?.code, data?.targetId); eventEmitter.remove(); } }, ); } } logger.logObject('joinChatRoom', { targetId, messageCount, autoCreate, callback, eventId }); return RCReactNativeIM.joinChatRoom(targetId, messageCount, autoCreate, eventId); } /** * [ZH] * --- * 退出聊天室。 * @param targetId 聊天室会话 ID * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Exit the chatroom. * @param targetId The conversation ID of the chatroom. * @param callback The event callback. The SDK has supported callback-style * callbacks since version 5.3.1. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. Refer to the error codes for detailed errors. * --- */ leaveChatRoom(targetId: string, callback?: IRCIMIWLeaveChatRoomCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onChatRoomLeft } = callback; if (onChatRoomLeft) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'LeaveChatRoom:onChatRoomLeft', (data: any) => { if (data?.eventId === eventId) { onChatRoomLeft && onChatRoomLeft(data?.code, data?.targetId); eventEmitter.remove(); } }, ); } } logger.logObject('leaveChatRoom', { targetId, callback, eventId }); return RCReactNativeIM.leaveChatRoom(targetId, eventId); } /** * [ZH] * --- * 获取聊天室历史消息记录。 * 注:必须先开通聊天室消息云存储功能。 * @param targetId 聊天室会话 ID * @param timestamp 起始的消息发送时间戳 * @param order 拉取顺序 0:倒序,1:正序 * @param count 要获取的消息数量,0 < count ≤ 50。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve chatroom historical messages. * Note: The chatroom message cloud storage feature must be enabled * first. * @param targetId The chatroom conversation ID * @param timestamp The starting message timestamp * @param order The order of retrieval: 0 for descending, 1 for ascending * @param count The number of messages to retrieve, where 0 < count ≤ 50 * @param callback The event callback. The SDK supports callback-style * responses starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result requires implementing the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ getChatRoomMessages( targetId: string, timestamp: number, order: RCIMIWTimeOrder, count: number, callback?: IRCIMIWGetChatRoomMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetChatRoomMessages:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetChatRoomMessages:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getChatRoomMessages', { targetId, timestamp, order, count, callback, eventId }); return RCReactNativeIM.getChatRoomMessages(targetId, timestamp, order, count, eventId); } /** * [ZH] * --- * 设置聊天室自定义属性。 * @param targetId 聊天室会话 ID * @param key 聊天室属性名称,Key 支持大小写英文字母、数字、部分特殊符号 + = - _ 的组合方式,最大长度 128 * 个字符 * @param value 聊天室属性对应的值,最大长度 4096 个字符 * @param deleteWhenLeft 用户掉线或退出时,是否自动删除该 Key、Value 值 * @param overwrite 如果当前 key 存在,是否进行覆盖 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set chatroom custom attributes. * @param targetId The conversation ID of the chatroom. * @param key The name of the chatroom attribute. The key supports a * combination of uppercase and lowercase letters, * numbers, and special characters + = - _. The maximum * length is 128 characters. * @param value The value corresponding to the chatroom attribute. The * maximum length is 4096 characters. * @param deleteWhenLeft Whether to automatically delete the key-value pair when * the user goes offline or exits the chatroom. * @param overwrite Whether to overwrite the existing key if it already * exists. * @param callback The event callback. SDK supports callback method * starting from version 5.3.1. Other callback methods for * this interface are deprecated starting from version * 5.4.0 and are expected to be removed in version 6.x. If * the callback parameter is provided, only the callback * method will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. Refer to the error codes for detailed error information. * --- */ addChatRoomEntry( targetId: string, key: string, value: string, deleteWhenLeft: boolean, overwrite: boolean, callback?: IRCIMIWAddChatRoomEntryCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onChatRoomEntryAdded } = callback; if (onChatRoomEntryAdded) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'AddChatRoomEntry:onChatRoomEntryAdded', (data: any) => { if (data?.eventId === eventId) { onChatRoomEntryAdded && onChatRoomEntryAdded(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('addChatRoomEntry', { targetId, key, value, deleteWhenLeft, overwrite, callback, eventId }); return RCReactNativeIM.addChatRoomEntry(targetId, key, value, deleteWhenLeft, overwrite, eventId); } /** * [ZH] * --- * 批量设置聊天室自定义属性 * @param targetId 聊天室会话 ID * @param entries 聊天室属性 * @param deleteWhenLeft 用户掉线或退出时,是否自动删除该 Key、Value 值 * @param overwrite 是否强制覆盖 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Batch Set Chatroom Custom Attributes * @param targetId Chatroom conversation ID * @param entries Chatroom attributes * @param deleteWhenLeft Whether to automatically delete the Key and Value when * the user goes offline or exits * @param overwrite Whether to force overwrite * @param callback Event callback. The SDK supports callback-style * callbacks starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If * the callback parameter is provided, only the callback * will be triggered. * @return The status code for the current operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * interface callback. A non-zero value indicates that the current * interface call failed, and the interface callback will not be * triggered. For detailed errors, refer to the error codes. * --- */ addChatRoomEntries( targetId: string, entries: Map, deleteWhenLeft: boolean, overwrite: boolean, callback?: IRCIMIWAddChatRoomEntriesCallback, ): Promise { let _entries: any = Object.fromEntries(entries); const eventId = Math.random().toString(); if (callback) { const { onChatRoomEntriesAdded } = callback; if (onChatRoomEntriesAdded) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'AddChatRoomEntries:onChatRoomEntriesAdded', (data: any) => { if (data?.eventId === eventId) { onChatRoomEntriesAdded && onChatRoomEntriesAdded(data?.code, data?.errors); eventEmitter.remove(); } }, ); } } logger.logObject('addChatRoomEntries', { targetId, entries, deleteWhenLeft, overwrite, callback, eventId }); return RCReactNativeIM.addChatRoomEntries(targetId, _entries, deleteWhenLeft, overwrite, eventId); } /** * [ZH] * --- * 获取聊天室单个属性。 * @param targetId 聊天室会话 ID * @param key 聊天室属性键值 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve a single chatroom attribute. * @param targetId The conversation ID of the chatroom * @param key The key of the chatroom attribute * @param callback The event callback. SDK supports callback-style callbacks * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ getChatRoomEntry(targetId: string, key: string, callback?: IRCIMIWGetChatRoomEntryCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetChatRoomEntry:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetChatRoomEntry:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getChatRoomEntry', { targetId, key, callback, eventId }); return RCReactNativeIM.getChatRoomEntry(targetId, key, eventId); } /** * [ZH] * --- * 获取聊天室所有属性。 * @param targetId 聊天室会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve all attributes of a chatroom. * @param targetId The conversation ID of the chatroom. * @param callback The event callback. Starting from SDK version 5.3.1, the * callback method is supported. From version 5.4.0, other * callback methods for this interface are deprecated and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * interface call failed, and no interface callback will be triggered. * For detailed error information, refer to the error codes. * --- */ getChatRoomAllEntries(targetId: string, callback?: IRCIMIWGetChatRoomAllEntriesCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetChatRoomAllEntries:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetChatRoomAllEntries:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getChatRoomAllEntries', { targetId, callback, eventId }); return RCReactNativeIM.getChatRoomAllEntries(targetId, eventId); } /** * [ZH] * --- * 删除聊天室自定义属性。 * @param targetId 聊天室会话 ID * @param key 聊天室属性键值 * @param force 是否强制删除 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove chatroom custom attributes. * @param targetId The chatroom conversation ID * @param key The chatroom attribute key * @param force Whether to force deletion * @param callback The event callback. SDK supports callback method starting * from version 5.3.1. Other callback methods for this interface * are deprecated as of version 5.4.0 and are expected to be * removed in version 6.x. If the callback parameter is * provided, only the callback method will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current operation * failed, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ removeChatRoomEntry( targetId: string, key: string, force: boolean, callback?: IRCIMIWRemoveChatRoomEntryCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onChatRoomEntryRemoved } = callback; if (onChatRoomEntryRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveChatRoomEntry:onChatRoomEntryRemoved', (data: any) => { if (data?.eventId === eventId) { onChatRoomEntryRemoved && onChatRoomEntryRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeChatRoomEntry', { targetId, key, force, callback, eventId }); return RCReactNativeIM.removeChatRoomEntry(targetId, key, force, eventId); } /** * [ZH] * --- * 批量删除聊天室自定义属性 * @param targetId 聊天室会话 ID * @param keys 聊天室属性 * @param force 是否强制覆盖 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Batch Delete Chatroom Custom Attributes * @param targetId The chatroom conversation ID * @param keys The chatroom attributes * @param force Specifies whether to force overwrite * @param callback The event callback. SDK supports callback mode from version * 5.3.1. Other callback methods for this interface are * deprecated starting from version 5.4.0 and will be removed in * version 6.x. If the callback parameter is provided, only the * callback will be triggered. * @return The status code of the current interface operation. 0 indicates * successful invocation, and specific results need to be handled in the * interface callback. Non-zero values indicate that the current * interface invocation failed, and no callback will be triggered. Refer * to the error codes for detailed error information. * --- */ removeChatRoomEntries( targetId: string, keys: Array, force: boolean, callback?: IRCIMIWRemoveChatRoomEntriesCallback, ): Promise { if (keys) { keys = keys.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onChatRoomEntriesRemoved } = callback; if (onChatRoomEntriesRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveChatRoomEntries:onChatRoomEntriesRemoved', (data: any) => { if (data?.eventId === eventId) { onChatRoomEntriesRemoved && onChatRoomEntriesRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeChatRoomEntries', { targetId, keys, force, callback, eventId }); return RCReactNativeIM.removeChatRoomEntries(targetId, keys, force, eventId); } /** * [ZH] * --- * 将某个用户加入黑名单。 * 当你把对方加入黑名单后,对方再发消息时,就会提示“已被加入黑名单,消息发送失败”。 但你依然可以发消息个对方。 * @param userId 用户 Id * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Add a user to the blocklist. * When you add a user to the blocklist, they will receive a * notification stating "You have been added to the blocklist, message * sending failed" when attempting to send you a message. However, you * can still send messages to them. * @param userId User ID * @param callback Event callback. The SDK has supported callback-style * callbacks since version 5.3.1. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current interface * call operation failed, and no interface callback will be triggered. * Refer to the error codes for detailed error information. * --- */ addToBlacklist(userId: string, callback?: IRCIMIWAddToBlacklistCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onBlacklistAdded } = callback; if (onBlacklistAdded) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'AddToBlacklist:onBlacklistAdded', (data: any) => { if (data?.eventId === eventId) { onBlacklistAdded && onBlacklistAdded(data?.code, data?.userId); eventEmitter.remove(); } }, ); } } logger.logObject('addToBlacklist', { userId, callback, eventId }); return RCReactNativeIM.addToBlacklist(userId, eventId); } /** * [ZH] * --- * 将某个用户从黑名单中移出。 * @param userId 用户 Id * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove a user from the blocklist. * @param userId User ID * @param callback Event callback. The SDK supports callback-based event * handling starting from version 5.3.1. Other callback methods * for this interface have been deprecated as of version 5.4.0 * and are expected to be removed in version 6.x. If a callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * interface callback. Non-zero values indicate that the current * operation failed, and no callback will be triggered. Refer to the * error codes for detailed error information. * --- */ removeFromBlacklist(userId: string, callback?: IRCIMIWRemoveFromBlacklistCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onBlacklistRemoved } = callback; if (onBlacklistRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveFromBlacklist:onBlacklistRemoved', (data: any) => { if (data?.eventId === eventId) { onBlacklistRemoved && onBlacklistRemoved(data?.code, data?.userId); eventEmitter.remove(); } }, ); } } logger.logObject('removeFromBlacklist', { userId, callback, eventId }); return RCReactNativeIM.removeFromBlacklist(userId, eventId); } /** * [ZH] * --- * 获取某用户是否在黑名单中。 * @param userId 用户 Id * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Check if a user is in the blocklist. * @param userId User ID * @param callback Event callback. The SDK supports callback-style responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be obtained through the interface * callback. Non-zero values indicate a failure in the current * operation, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ getBlacklistStatus(userId: string, callback?: IRCIMIWGetBlacklistStatusCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBlacklistStatus:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBlacklistStatus:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getBlacklistStatus', { userId, callback, eventId }); return RCReactNativeIM.getBlacklistStatus(userId, eventId); } /** * [ZH] * --- * 获取当前用户设置的黑名单列表。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the current user's blocklist. * @param callback Event callback. The SDK has supported callback-style * responses since version 5.3.1. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be handled in the * interface callback. Non-zero values indicate that the current * interface call failed, and no interface callback will be triggered. * For detailed error information, refer to the error codes. * --- */ getBlacklist(callback?: IRCIMIWGetBlacklistCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetBlacklist:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetBlacklist:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getBlacklist', { callback, eventId }); return RCReactNativeIM.getBlacklist(eventId); } /** * [ZH] * --- * 根据关键字搜索指定会话中的消息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param keyword 搜索的关键字 * @param startTime 查询 beginTime 之前的消息, 传 0 时从最新消息开始搜索,从该时间往前搜索。 * @param count 查询的数量,0 < count ≤ 50。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Search for messages in a specified conversation based on keywords. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param keyword Keyword to search for * @param startTime Search for messages before this timestamp. Pass 0 to start * searching from the latest message and move backward in time. * @param count Number of messages to query, where 0 < count ≤ 50. * @param callback Event callback. The SDK has supported callback-based * responses since version 5.3.1. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and specific results need to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ searchMessages( type: RCIMIWConversationType, targetId: string, channelId: string, keyword: string, startTime: number, count: number, callback?: IRCIMIWSearchMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('SearchMessages:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('SearchMessages:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('searchMessages', { type, targetId, channelId, keyword, startTime, count, callback, eventId }); return RCReactNativeIM.searchMessages(type, targetId, channelId, keyword, startTime, count, eventId); } /** * [ZH] * --- * 根据关键字搜索指定会话中某个时间段的消息。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param keyword 搜索的关键字 * @param startTime 开始时间 * @param endTime 结束时间 * @param offset 偏移量 * @param count 返回的搜索结果数量,0 < count ≤ 50。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Search for messages within a specified time range in a conversation * based on a keyword. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other * conversation types, pass null. * @param keyword Keyword to search for * @param startTime Start time * @param endTime End time * @param offset Offset * @param count Number of search results to return, where 0 < count ≤ 50. * @param callback Event callback. The SDK supports callback-style event * handling starting from version 5.3.1. Other callback methods * for this interface are deprecated as of version 5.4.0 and * will be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return Status code for the current operation. 0 indicates a successful call, * and specific results need to be handled in the callback. Non-zero * values indicate a failure in the current operation, and no callback * will be triggered. Refer to the error codes for detailed error * information. * --- */ searchMessagesByTimeRange( type: RCIMIWConversationType, targetId: string, channelId: string, keyword: string, startTime: number, endTime: number, offset: number, count: number, callback?: IRCIMIWSearchMessagesByTimeRangeCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByTimeRange:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByTimeRange:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('searchMessagesByTimeRange', { type, targetId, channelId, keyword, startTime, endTime, offset, count, callback, eventId, }); return RCReactNativeIM.searchMessagesByTimeRange( type, targetId, channelId, keyword, startTime, endTime, offset, count, eventId, ); } /** * [ZH] * --- * 根据用户 id 搜索指定会话中的消息。 * @param userId 用户 id * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param startTime 查询记录的起始时间, 传 0 时从最新消息开始搜索,从该时间往前搜索。 * @param count 返回的搜索结果数量 0 < count ≤ 50。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Search for messages in a specified conversation based on user ID. * @param userId User ID * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass `null` for * other conversation types. * @param startTime Start time for the query. Pass `0` to start searching from * the latest message and search backward from that time. * @param count Number of search results to return. Must be in the range 0 < * count ≤ 50. * @param callback Event callback. The SDK supports callback mode starting from * version 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and are expected to be * removed in version 6.x. If the `callback` parameter is * provided, only the callback will be triggered. * @return Status code of the current operation. `0` indicates a successful * call, and specific results need to be implemented in the interface * callback. Non-zero values indicate a failure in the current * operation, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ searchMessagesByUserId( userId: string, type: RCIMIWConversationType, targetId: string, channelId: string, startTime: number, count: number, callback?: IRCIMIWSearchMessagesByUserIdCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByUserId:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByUserId:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('searchMessagesByUserId', { userId, type, targetId, channelId, startTime, count, callback, eventId, }); return RCReactNativeIM.searchMessagesByUserId(userId, type, targetId, channelId, startTime, count, eventId); } /** * [ZH] * --- * 根据关键字搜索指定会话中,指定消息类型的本地历史消息。 * @param type 会话类型。 * @param targetId 会话 ID。 * @param channelId 消息所属的会话标识。 * @param messageTypes 消息类型集合。 * @param keyword 搜索的关键字,非空。 * @param startTime 查询 startTime 之前的消息(传 0 表示从最新消息开始搜索),单位:毫秒 * @param count 最大的查询数量,最大 100。 * @param callback 搜索结果的回调接口 * @return 当次接口操作的状态码。0 代表调用成功 具体结果通过接口 callback 回调,非 0 * 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Search local message history by keyword in specified conversation * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel identifier for messages * @param messageTypes Set of message types * @param keyword Search keyword (required) * @param startTime Search messages before this timestamp (0 means start from * latest) in milliseconds * @param count Max results (up to 100) * @param callback Callback for search results * @return Status code: 0 for success (results via callback), non-zero for * failure (see error codes) * --- */ searchMessagesByMessageTypes( type: RCIMIWConversationType, targetId: string, channelId: string, messageTypes: Array, keyword: string, startTime: number, count: number, callback?: IRCIMIWSearchMessagesByMessageTypesCallback, ): Promise { if (messageTypes) { messageTypes = messageTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByMessageTypes:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchMessagesByMessageTypes:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('searchMessagesByMessageTypes', { type, targetId, channelId, messageTypes, keyword, startTime, count, callback, eventId, }); return RCReactNativeIM.searchMessagesByMessageTypes( type, targetId, channelId, messageTypes, keyword, startTime, count, eventId, ); } /** * [ZH] * --- * 根据关键字搜索会话。 * @param conversationTypes 会话类型集合 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param messageTypes 搜索的消息类型 * @param keyword 搜索的关键字。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback * 参数,仅触发 callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Search conversations by keyword. * @param conversationTypes Collection of conversation types * @param channelId Channel ID, only supported for ultra groups. Pass * null for other conversation types. * @param messageTypes Message types to search for * @param keyword Keyword to search for * @param callback Event callback. SDK supports callback mode from * version 5.3.1. Other callback methods for this * interface are deprecated starting from version 5.4.0 * and are expected to be removed in version 6.x. If * the callback parameter is provided, only the * callback will be triggered. * @return Status code for the current operation. 0 indicates a successful call. * Specific results need to be implemented via the interface callback. * Non-zero values indicate that the current interface call operation * failed and will not trigger the interface callback. Refer to the * error codes for detailed error information. * --- */ searchConversations( conversationTypes: Array, channelId: string, messageTypes: Array, keyword: string, callback?: IRCIMIWSearchConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } if (messageTypes) { messageTypes = messageTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchConversations:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SearchConversations:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('searchConversations', { conversationTypes, channelId, messageTypes, keyword, callback, eventId, }); return RCReactNativeIM.searchConversations(conversationTypes, channelId, messageTypes, keyword, eventId); } /** * [ZH] * --- * 屏蔽某个时间段的消息提醒 * @param startTime 开始消息免打扰时间,格式为 HH:MM:SS * @param spanMinutes 需要消息免打扰分钟数,0 < spanMinutes < 1440( 比如,您设置的起始时间是 00:00, * 结束时间为 01:00,则 spanMinutes 为 60 分钟。设置为 1439 代表全天免打扰 (23 * 60 + 59 = 1439 )) * @param level 消息通知级别 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * ### Mute Message Notifications for a Specific Time Period * @param startTime * Specifies the start time for muting message notifications, * in the format `HH:MM:SS`. * @param spanMinutes * The duration in minutes for muting message notifications, * where `0 < spanMinutes < 1440`. * For example, if the start time is `00:00` and the end time * is `01:00`, then `spanMinutes` would be `60`. Setting it * to `1439` represents a full day of muting (`23 60 + 59 = * 1439`). * @param level * The notification level for messages. * @param callback * The event callback. Starting from SDK version 5.3.1, the * callback method is supported. Other callback methods for * this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the `callback` * parameter is provided, only the callback method will be * triggered. * @return * The status code for the current operation. `0` indicates a successful * call, and the specific result requires implementing the callback * interface. Non-zero values indicate that the current operation * failed, and the callback will not be triggered. Refer to the error * codes for detailed error information. * --- */ changeNotificationQuietHours( startTime: string, spanMinutes: number, level: RCIMIWPushNotificationQuietHoursLevel, callback?: IRCIMIWChangeNotificationQuietHoursCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onNotificationQuietHoursChanged } = callback; if (onNotificationQuietHoursChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeNotificationQuietHours:onNotificationQuietHoursChanged', (data: any) => { if (data?.eventId === eventId) { onNotificationQuietHoursChanged && onNotificationQuietHoursChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeNotificationQuietHours', { startTime, spanMinutes, level, callback, eventId }); return RCReactNativeIM.changeNotificationQuietHours(startTime, spanMinutes, level, eventId); } /** * [ZH] * --- * 删除已设置的全局时间段消息提醒屏蔽 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove the globally set time period message reminder mute * @param callback Event callback. The SDK supports callback-style callbacks * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented via * the interface callback. Non-zero indicates that the current interface * call operation failed, and no interface callback will be triggered. * Refer to the error codes for detailed errors. * --- */ removeNotificationQuietHours(callback?: IRCIMIWRemoveNotificationQuietHoursCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onNotificationQuietHoursRemoved } = callback; if (onNotificationQuietHoursRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveNotificationQuietHours:onNotificationQuietHoursRemoved', (data: any) => { if (data?.eventId === eventId) { onNotificationQuietHoursRemoved && onNotificationQuietHoursRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeNotificationQuietHours', { callback, eventId }); return RCReactNativeIM.removeNotificationQuietHours(eventId); } /** * [ZH] * --- * 获取已设置的时间段消息提醒屏蔽 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * ### Get the Set Time Period for Message Reminder Blocking * @param callback Event callback. The SDK has supported callback-based event * handling since version 5.3.1. Starting from version 5.4.0, * other callback methods for this interface have been * deprecated and are expected to be removed in version 6.x. If * the `callback` parameter is provided, only the callback * method will be triggered. * @return The status code for the current operation. `0` indicates a successful * call, and the specific result needs to be handled in the interface * callback. A non-zero value indicates that the current operation * failed, and the interface callback will not be triggered. Refer to * the error codes for detailed error information. * --- */ getNotificationQuietHours(callback?: IRCIMIWGetNotificationQuietHoursCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetNotificationQuietHours:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.startTime, data?.spanMinutes, data?.level); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetNotificationQuietHours:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getNotificationQuietHours', { callback, eventId }); return RCReactNativeIM.getNotificationQuietHours(eventId); } /** * [ZH] * --- * 设置会话的消息提醒状态 * 注:超级群调用该接口,channelId 为空时,相当于设置了 channelId 为空的频道的免打扰,不会屏蔽整个超级群会话下所有频道的免打扰 * @param type 会话类型。请注意以下限制:*超级群会话类型*:如在 2022.09.01 * 之前开通超级群业务,默认不支持为单个超级群会话*所有消息*设置免打扰级别(“所有消息”指所有频道中的消息和不属于任何频道的消息)。该接口仅设置指定超级群会话(`targetId`)中*不属于任何频道的消息*的免打扰状态级别。如需修改请提交工单。*聊天室会话类型*:不支持,因为聊天室消息默认不支持消息推送提醒。 * @param targetId 会话 ID * @param channelId 超级群的会话频道 ID。其他类型传 null 即可。如果传入频道 * ID,则针对该指定频道设置消息免打扰级别。如果不指定频道 * ID,则对所有超级群消息生效。*注意*:2022.09.01 之前开通超级群业务的客户,如果不指定频道 * ID,则默认传 "" * 空字符串,即仅针对指定超级群会话(`targetId`)中*不属于任何频道的消息*设置免打扰状态级别。如需修改请提交工单。 * @param level 消息通知级别 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the message notification level for a conversation * Note: When calling this API for an ultra group, if `channelId` is * empty, it sets the Do Not Disturb level for messages not belonging * to any channel within the specified ultra group conversation. This * does not affect the Do Not Disturb settings for all channels within * the ultra group conversation. * @param type The conversation type. Please note the following * restrictions: * Ultra group conversation type: For ultra group services * activated before 2022.09.01, setting the Do Not Disturb * level for all messages in a single ultra group conversation * (where "all messages" refers to messages across all channels * and messages not belonging to any channel) is not supported * by default. This API only sets the Do Not Disturb level for * messages not belonging to any channel within the specified * ultra group conversation (`targetId`). To modify this * behavior, submit a ticket. * Chatroom conversation type: Not supported, as chatroom * messages do not support push notifications by default. * @param targetId The conversation ID. * @param channelId The channel ID for the ultra group conversation. Pass `null` * for other types. * If a channel ID is provided, the Do Not Disturb level is set * for the specified channel. If no channel ID is specified, it * applies to all messages in the ultra group. * Note: For ultra group services activated before 2022.09.01, * if no channel ID is specified, pass an empty string `""`, * which sets the Do Not Disturb level only for messages not * belonging to any channel within the specified ultra group * conversation (`targetId`). To modify this behavior, submit a * ticket. * @param level The message notification level. * @param callback The event callback. Starting from SDK version 5.3.1, * callback is supported. Other callback methods for this API * are deprecated as of version 5.4.0 and will be removed in * version 6.x. If the `callback` parameter is provided, only * the callback will be triggered. * @return The status code for the current API operation. `0` indicates a * successful call, and the specific result needs to be handled in the * callback. Non-zero values indicate a failed API call, and no callback * will be triggered. Refer to the error codes for detailed error * information. * --- */ changeConversationNotificationLevel( type: RCIMIWConversationType, targetId: string, channelId: string, level: RCIMIWPushNotificationLevel, callback?: IRCIMIWChangeConversationNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationNotificationLevelChanged } = callback; if (onConversationNotificationLevelChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeConversationNotificationLevel:onConversationNotificationLevelChanged', (data: any) => { if (data?.eventId === eventId) { onConversationNotificationLevelChanged && onConversationNotificationLevelChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeConversationNotificationLevel', { type, targetId, channelId, level, callback, eventId, }); return RCReactNativeIM.changeConversationNotificationLevel(type, targetId, channelId, level, eventId); } /** * [ZH] * --- * 获取会话的消息提醒状态 * @param type 会话类型。请注意以下限制:*超级群会话类型*:如在 2022.09.01 * 之前开通超级群业务,默认不支持为单个超级群会话*所有消息*设置免打扰级别(“所有消息”指所有频道中的消息和不属于任何频道的消息)。该接口仅设置指定超级群会话(`targetId`)中*不属于任何频道的消息*的免打扰状态级别。如需修改请提交工单。*聊天室会话类型*:不支持,因为聊天室消息默认不支持消息推送提醒。 * @param targetId 会话 ID * @param channelId 超级群的会话频道 ID。其他类型传 null 即可。如果传入频道 * ID,则针对该指定频道设置消息免打扰级别。如果不指定频道 * ID,则对所有超级群消息生效。*注意*:2022.09.01 之前开通超级群业务的客户,如果不指定频道 * ID,则默认传 "" * 空字符串,即仅针对指定超级群会话(`targetId`)中*不属于任何频道的消息*设置免打扰状态级别。如需修改请提交工单。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get Conversation Notification Level * @param type Conversation type. Please note the following restrictions: * Ultra group conversation type: If the ultra group service * was activated before 2022.09.01, it does not support setting * the Do Not Disturb level for all messages in a single ultra * group conversation by default ("all messages" refers to * messages in all channels and messages not belonging to any * channel). This API only sets the Do Not Disturb level for * messages in the specified ultra group conversation * (`targetId`) that do not belong to any channel. Submit a * ticket if modification is required.Chatroom conversation * type: Not supported, as chatroom messages do not support * push notifications by default. * @param targetId Conversation ID * @param channelId Channel ID of the ultra group conversation. Pass `null` for * other types. * If a channel ID is provided, the Do Not Disturb level will * be set for messages in that specific channel. If no channel * ID is specified, it will apply to all ultra group * messages.Note: For customers who activated the ultra group * service before 2022.09.01, if no channel ID is specified, * pass an empty string `""` by default, which means the Do Not * Disturb level will only be set for messages in the specified * ultra group conversation (`targetId`) that do not belong to * any channel. Submit a ticket if modification is required. * @param callback Event callback. The SDK supports callback-style response * starting from version 5.3.1. Other callback methods for this * API are deprecated as of version 5.4.0 and are expected to * be removed in version 6.x. If the `callback` parameter is * provided, only the callback will be triggered. * @return The status code of the current API operation. `0` indicates a * successful call, and the specific result needs to be implemented in * the callback. Non-zero values indicate that the current API call * failed, and no callback will be triggered. Refer to the error codes * for detailed error information. * --- */ getConversationNotificationLevel( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetConversationNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationNotificationLevel:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationNotificationLevel:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationNotificationLevel', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getConversationNotificationLevel(type, targetId, channelId, eventId); } /** * [ZH] * --- * 设置会话类型的消息提醒状态 * 注:如要移除消息提醒状态,设置level为RCIMIWPushNotificationLevelDefault * @param type 会话类型 * @param level 消息通知级别 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the message notification level for a conversation type * Note: To remove the message notification level, set the level to * `RCIMIWPushNotificationLevelDefault`. * @param type The conversation type * @param level The message notification level * @param callback The event callback. The SDK supports callback-based event * handling starting from version 5.3.1. Other callback methods * for this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the `callback` * parameter is provided, only the callback method will be * triggered. * @return The status code of the current operation. `0` indicates a successful * call, and the specific result needs to be handled in the interface * callback. A non-zero value indicates that the operation failed, and * the interface callback will not be triggered. Refer to the error * codes for detailed error information. * --- */ changeConversationTypeNotificationLevel( type: RCIMIWConversationType, level: RCIMIWPushNotificationLevel, callback?: IRCIMIWChangeConversationTypeNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationTypeNotificationLevelChanged } = callback; if (onConversationTypeNotificationLevelChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeConversationTypeNotificationLevel:onConversationTypeNotificationLevelChanged', (data: any) => { if (data?.eventId === eventId) { onConversationTypeNotificationLevelChanged && onConversationTypeNotificationLevelChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeConversationTypeNotificationLevel', { type, level, callback, eventId }); return RCReactNativeIM.changeConversationTypeNotificationLevel(type, level, eventId); } /** * [ZH] * --- * 获取会话类型的消息提醒状态 * @param type 会话类型 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the notification level for a specific conversation type. * @param type Specifies the conversation type. * @param callback Event callback. The SDK has supported callback-based event * handling since version 5.3.1. Other callback methods for this * interface were deprecated in version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result requires the implementation of the * interface callback. Non-zero indicates that the current interface * call failed, and no interface callback will be triggered. Refer to * the error codes for detailed errors. * --- */ getConversationTypeNotificationLevel( type: RCIMIWConversationType, callback?: IRCIMIWGetConversationTypeNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTypeNotificationLevel:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTypeNotificationLevel:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationTypeNotificationLevel', { type, callback, eventId }); return RCReactNativeIM.getConversationTypeNotificationLevel(type, eventId); } /** * [ZH] * --- * 设置超级群的默认消息状态 * 一般由管理员设置的接口,针对超级群的所有群成员生效,针对超级群下所有频道生效,优先级较低。如果群成员自己超级群的免打扰级别,那么以群成员自己设置的为准。 * @param targetId 会话 ID * @param level 消息通知级别 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the default message status for ultra groups * This interface is typically used by administrators and applies to * all members of the ultra group and all channels under the ultra * group, with a lower priority. If a group member sets their own Do * Not Disturb level for the ultra group, the member's setting takes * precedence. * @param targetId The conversation ID * @param level The message notification level * @param callback The event callback. Starting from SDK version 5.3.1, callback * method is supported. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in the 6.x version. If the callback parameter * is provided, only the callback method will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and specific results need to be implemented via the interface * callback. Non-zero values indicate a failure in the current * operation, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ changeUltraGroupDefaultNotificationLevel( targetId: string, level: RCIMIWPushNotificationLevel, callback?: IRCIMIWChangeUltraGroupDefaultNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupDefaultNotificationLevelChanged } = callback; if (onUltraGroupDefaultNotificationLevelChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeUltraGroupDefaultNotificationLevel:onUltraGroupDefaultNotificationLevelChanged', (data: any) => { if (data?.eventId === eventId) { onUltraGroupDefaultNotificationLevelChanged && onUltraGroupDefaultNotificationLevelChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeUltraGroupDefaultNotificationLevel', { targetId, level, callback, eventId }); return RCReactNativeIM.changeUltraGroupDefaultNotificationLevel(targetId, level, eventId); } /** * [ZH] * --- * 获取超级群的默认消息状态 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the default message status of an ultra group * @param targetId The conversation ID * @param callback The event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * operation failed, and the interface callback will not be triggered. * Refer to the error codes for detailed error information. * --- */ getUltraGroupDefaultNotificationLevel( targetId: string, callback?: IRCIMIWGetUltraGroupDefaultNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupDefaultNotificationLevel:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupDefaultNotificationLevel:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupDefaultNotificationLevel', { targetId, callback, eventId }); return RCReactNativeIM.getUltraGroupDefaultNotificationLevel(targetId, eventId); } /** * [ZH] * --- * 设置超级群频道的默认消息状态 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用。 * @param level 消息通知级别 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the default message status for an ultra group channel * @param targetId The conversation ID * @param channelId The channel ID, only supported for ultra groups * @param level The message notification level * @param callback The event callback. The SDK has supported callback-based * event handling since version 5.3.1. Other callback methods * for this interface were deprecated in version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback method will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * interface call failed, and the interface callback will not be * triggered. For detailed error information, refer to the error codes. * --- */ changeUltraGroupChannelDefaultNotificationLevel( targetId: string, channelId: string, level: RCIMIWPushNotificationLevel, callback?: IRCIMIWChangeUltraGroupChannelDefaultNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupChannelDefaultNotificationLevelChanged } = callback; if (onUltraGroupChannelDefaultNotificationLevelChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeUltraGroupChannelDefaultNotificationLevel:onUltraGroupChannelDefaultNotificationLevelChanged', (data: any) => { if (data?.eventId === eventId) { onUltraGroupChannelDefaultNotificationLevelChanged && onUltraGroupChannelDefaultNotificationLevelChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeUltraGroupChannelDefaultNotificationLevel', { targetId, channelId, level, callback, eventId, }); return RCReactNativeIM.changeUltraGroupChannelDefaultNotificationLevel(targetId, channelId, level, eventId); } /** * [ZH] * --- * 获取超级群频道的默认消息状态 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the default message status of an ultra group channel * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. * @param callback Event callback. The SDK supports callback-style responses * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback method will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * interface call failed, and no callback will be triggered. Refer to * the error codes for detailed error information. * --- */ getUltraGroupChannelDefaultNotificationLevel( targetId: string, channelId: string, callback?: IRCIMIWGetUltraGroupChannelDefaultNotificationLevelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupChannelDefaultNotificationLevel:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUltraGroupChannelDefaultNotificationLevel:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUltraGroupChannelDefaultNotificationLevel', { targetId, channelId, callback, eventId }); return RCReactNativeIM.getUltraGroupChannelDefaultNotificationLevel(targetId, channelId, eventId); } /** * [ZH] * --- * 设置是否显示远程推送内容详情,此功能需要从服务端开启用户设置功能。 * @param showContent 是否显示远程推送内容 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set whether to display the details of remote push notifications. * This feature requires enabling user settings from the server side. * @param showContent Indicates whether to display the content of remote push * notifications. * @param callback The event callback. SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be * triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current * interface call operation failed, and the interface callback will not * be triggered. For detailed errors, refer to the error codes. * --- */ changePushContentShowStatus( showContent: boolean, callback?: IRCIMIWChangePushContentShowStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onPushContentShowStatusChanged } = callback; if (onPushContentShowStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangePushContentShowStatus:onPushContentShowStatusChanged', (data: any) => { if (data?.eventId === eventId) { onPushContentShowStatusChanged && onPushContentShowStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changePushContentShowStatus', { showContent, callback, eventId }); return RCReactNativeIM.changePushContentShowStatus(showContent, eventId); } /** * [ZH] * --- * 设置推送语言 * @param language 推送语言, 目前仅支持 en_us、zh_cn、ar_sa * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set Push Language * @param language The push language. Currently supports en_us, zh_cn, and * ar_sa. * @param callback The event callback. The SDK has supported callback-based * notifications since version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code for the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * interface call failed, and no interface callback will be triggered. * Refer to the error codes for detailed error information. * --- */ changePushLanguage(language: string, callback?: IRCIMIWChangePushLanguageCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onPushLanguageChanged } = callback; if (onPushLanguageChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangePushLanguage:onPushLanguageChanged', (data: any) => { if (data?.eventId === eventId) { onPushLanguageChanged && onPushLanguageChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changePushLanguage', { language, callback, eventId }); return RCReactNativeIM.changePushLanguage(language, eventId); } /** * [ZH] * --- * 设置是否接收远程推送。 * 前提:移动端未在线,Web 、MAC/PC 终端在线,移动端是否接收远程推送。 * 此功能需要从服务端开启用户设置功能。 * @param receive 是否接收 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set whether to receive remote push notifications. * Prerequisite: When the mobile client is offline, and Web or MAC/PC * clients are online, determine whether the mobile client receives * remote push notifications. * This feature requires enabling user settings from the server side. * @param receive Indicates whether to receive push notifications. * @param callback Event callback. The SDK supports callback mode starting from * version 5.3.1. Other callback modes for this interface are * deprecated as of version 5.4.0 and will be removed in version * 6.x. If the callback parameter is provided, only the callback * will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and specific results need to be handled via the callback. * Non-zero values indicate a failed operation, and no callback will be * triggered. Refer to the error codes for detailed error information. * --- */ changePushReceiveStatus(receive: boolean, callback?: IRCIMIWChangePushReceiveStatusCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onPushReceiveStatusChanged } = callback; if (onPushReceiveStatusChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangePushReceiveStatus:onPushReceiveStatusChanged', (data: any) => { if (data?.eventId === eventId) { onPushReceiveStatusChanged && onPushReceiveStatusChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changePushReceiveStatus', { receive, callback, eventId }); return RCReactNativeIM.changePushReceiveStatus(receive, eventId); } /** * [ZH] * --- * 给指定的群成员发送消息 * @param message 要发送的消息 * @param userIds 群成员集合 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * [onGroupMessageToDesignatedUsersSent] * --- * [EN] * --- * Send a message to specified group members * @param message The message to be sent * @param userIds The collection of group members * @param callback The event callback. The SDK supports callback-based response * starting from version 5.3.1. Other callback methods for this * interface are deprecated as of version 5.4.0 and are expected * to be removed in the 6.x release. If the callback parameter * is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * [onGroupMessageToDesignatedUsersSent] * --- */ sendGroupMessageToDesignatedUsers( message: RCIMIWMessage, userIds: Array, callback?: RCIMIWSendGroupMessageToDesignatedUsersCallback, ): Promise { if (userIds) { userIds = userIds.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onMessageSaved, onMessageSent } = callback; if (onMessageSaved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendGroupMessageToDesignatedUsers:onMessageSaved', (data: any) => { if (data?.eventId === eventId) { onMessageSaved && onMessageSaved(data?.message); eventEmitter.remove(); } }, ); } if (onMessageSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendGroupMessageToDesignatedUsers:onMessageSent', (data: any) => { if (data?.eventId === eventId) { onMessageSent && onMessageSent(data?.code, data?.message); eventEmitter.remove(); } }, ); } } logger.logObject('sendGroupMessageToDesignatedUsers', { message, userIds, callback, eventId }); return RCReactNativeIM.sendGroupMessageToDesignatedUsers(message, userIds, eventId); } /** * [ZH] * --- * 获取指定会话的消息总数。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the total number of messages for a specified conversation. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. Pass null for * other conversation types. * @param callback Event callback. The SDK supports callback mode starting from * version 5.3.1. Other callback methods for this interface are * deprecated in version 5.4.0 and will be removed in version * 6.x. If the callback parameter is provided, only the * callback will be triggered. * @return Status code for the current operation. 0 indicates success, and the * specific result needs to be implemented in the interface callback. * Non-zero values indicate failure of the current operation, and no * interface callback will be triggered. Refer to the error codes for * detailed error information. * --- */ getMessageCount( type: RCIMIWConversationType, targetId: string, channelId: string, callback?: IRCIMIWGetMessageCountCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageCount:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetMessageCount:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getMessageCount', { type, targetId, channelId, callback, eventId }); return RCReactNativeIM.getMessageCount(type, targetId, channelId, eventId); } /** * [ZH] * --- * 根据会话类型,获取置顶会话列表 * @param conversationTypes 会话类型集合 * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the list of pinned conversations based on conversation type. * @param conversationTypes A collection of conversation types. * @param channelId The channel ID, only supported for ultra groups. For * other conversation types, pass null. * @param callback The event callback. SDK supports callback method * starting from version 5.3.1. Other callback methods * for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. * If the callback parameter is provided, only the * callback method will be triggered. * @return The status code of the current interface operation. 0 indicates a * successful call, and specific results need to be implemented via the * interface callback. Non-zero values indicate that the current * interface call operation failed, and no interface callback will be * triggered. For detailed errors, refer to the error codes. * --- */ getTopConversations( conversationTypes: Array, channelId: string, callback?: IRCIMIWGetTopConversationsCallback, ): Promise { if (conversationTypes) { conversationTypes = conversationTypes.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTopConversations:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTopConversations:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getTopConversations', { conversationTypes, channelId, callback, eventId }); return RCReactNativeIM.getTopConversations(conversationTypes, channelId, eventId); } /** * [ZH] * --- * 上报超级群的已读时间 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用。 * @param timestamp 已读时间 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Report the read time of an ultra group. * @param targetId The conversation ID. * @param channelId The channel ID, only supported for ultra groups. * @param timestamp The read time. * @param callback The event callback. The SDK supports callback-style * responses starting from version 5.3.1. Other callback * methods for this interface are deprecated as of version * 5.4.0 and are expected to be removed in version 6.x. If the * callback parameter is provided, only the callback will be * triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the callback. * Non-zero values indicate a failure in the current operation, and no * callback will be triggered. Refer to the error codes for detailed * error information. * --- */ syncUltraGroupReadStatus( targetId: string, channelId: string, timestamp: number, callback?: IRCIMIWSyncUltraGroupReadStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupReadStatusSynced } = callback; if (onUltraGroupReadStatusSynced) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SyncUltraGroupReadStatus:onUltraGroupReadStatusSynced', (data: any) => { if (data?.eventId === eventId) { onUltraGroupReadStatusSynced && onUltraGroupReadStatusSynced(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('syncUltraGroupReadStatus', { targetId, channelId, timestamp, callback, eventId }); return RCReactNativeIM.syncUltraGroupReadStatus(targetId, channelId, timestamp, eventId); } /** * [ZH] * --- * 获取特定会话下所有频道的会话列表,只支持超级群 * @param type 会话类型 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the conversation list for all channels under a specific * conversation. Only supported for ultra groups. * @param type Conversation type * @param targetId Conversation ID * @param callback Event callback. SDK supports callback method starting from * version 5.3.1. Other callback methods for this interface are * deprecated as of version 5.4.0 and are expected to be removed * in version 6.x. If the callback parameter is provided, only * the callback method will be triggered. * @return Status code for the current operation. 0 indicates a successful call, * and specific results need to be implemented in the interface * callback. Non-zero values indicate that the current interface call * failed, and no interface callback will be triggered. Refer to the * error codes for detailed error information. * --- */ getConversationsForAllChannel( type: RCIMIWConversationType, targetId: string, callback?: IRCIMIWGetConversationsForAllChannelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsForAllChannel:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsForAllChannel:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationsForAllChannel', { type, targetId, callback, eventId }); return RCReactNativeIM.getConversationsForAllChannel(type, targetId, eventId); } /** * [ZH] * --- * 修改超级群消息 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值 * @param message 要修改的 message * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Modify Ultra Group Message * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param message The message to be modified. * @param callback Event callback. SDK supports callback-style callbacks * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled by the interface * callback. Non-zero values indicate that the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed error information. * --- */ modifyUltraGroupMessage( messageUId: string, message: RCIMIWMessage, callback?: IRCIMIWModifyUltraGroupMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessageModified } = callback; if (onUltraGroupMessageModified) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ModifyUltraGroupMessage:onUltraGroupMessageModified', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessageModified && onUltraGroupMessageModified(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('modifyUltraGroupMessage', { messageUId, message, callback, eventId }); return RCReactNativeIM.modifyUltraGroupMessage(messageUId, message, eventId); } /** * [ZH] * --- * 撤回超级群消息 * @param message 需要撤回的消息 * @param deleteRemote 是否删除远端消息 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Recall Ultra Group Message * @param message The message to be recalled * @param deleteRemote Whether to delete the remote message * @param callback Event callback. SDK supports callback mode starting from * version 5.3.1. Other callback methods for this interface * are deprecated in version 5.4.0 and will be removed in * version 6.x. If the callback parameter is provided, only * the callback will be triggered. * @return The status code of the current operation. 0 indicates the call was * successful, and specific results need to be implemented via the * interface callback. Non-zero indicates the current operation failed, * and no interface callback will be triggered. Refer to the error codes * for detailed errors. * --- */ recallUltraGroupMessage( message: RCIMIWMessage, deleteRemote: boolean, callback?: IRCIMIWRecallUltraGroupMessageCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessageRecalled } = callback; if (onUltraGroupMessageRecalled) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RecallUltraGroupMessage:onUltraGroupMessageRecalled', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessageRecalled && onUltraGroupMessageRecalled(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('recallUltraGroupMessage', { message, deleteRemote, callback, eventId }); return RCReactNativeIM.recallUltraGroupMessage(message, deleteRemote, eventId); } /** * [ZH] * --- * 删除超级群指定时间之前的消息 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用。 * @param timestamp 时间戳 * @param policy 清除策略 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete messages in an ultra group before a specified time * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. * @param timestamp Unix timestamp * @param policy Clear policy * @param callback Event callback. SDK supports callback method from version * 5.3.1. Other callback methods for this interface are * deprecated starting from version 5.4.0 and are expected to * be removed in version 6.x. If the callback parameter is * provided, only the callback method will be triggered. * @return Status code of the current operation. 0 indicates a successful call, * and the specific result needs to be implemented through the interface * callback. Non-zero indicates a failure in the current operation, and * the interface callback will not be triggered. Refer to the error * codes for detailed error information. * --- */ clearUltraGroupMessages( targetId: string, channelId: string, timestamp: number, policy: RCIMIWMessageOperationPolicy, callback?: IRCIMIWClearUltraGroupMessagesCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessagesCleared } = callback; if (onUltraGroupMessagesCleared) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearUltraGroupMessages:onUltraGroupMessagesCleared', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessagesCleared && onUltraGroupMessagesCleared(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearUltraGroupMessages', { targetId, channelId, timestamp, policy, callback, eventId }); return RCReactNativeIM.clearUltraGroupMessages(targetId, channelId, timestamp, policy, eventId); } /** * [ZH] * --- * 发送超级群输入状态 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用。 * @param typingStatus 输入状态 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Send Ultra Group Typing Status * @param targetId Conversation ID * @param channelId Channel ID, supported only for ultra groups. * @param typingStatus Typing status * @param callback Event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and * will be removed in the 6.x release. If the callback * parameter is provided, only the callback will be * triggered. * @return The status code for the current operation. 0 indicates success, and * the specific result needs to be handled in the interface callback. * Non-zero values indicate a failure in the current operation, and no * callback will be triggered. Refer to the error codes for detailed * error information. * --- */ sendUltraGroupTypingStatus( targetId: string, channelId: string, typingStatus: RCIMIWUltraGroupTypingStatus, callback?: IRCIMIWSendUltraGroupTypingStatusCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupTypingStatusSent } = callback; if (onUltraGroupTypingStatusSent) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'SendUltraGroupTypingStatus:onUltraGroupTypingStatusSent', (data: any) => { if (data?.eventId === eventId) { onUltraGroupTypingStatusSent && onUltraGroupTypingStatusSent(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('sendUltraGroupTypingStatus', { targetId, channelId, typingStatus, callback, eventId }); return RCReactNativeIM.sendUltraGroupTypingStatus(targetId, channelId, typingStatus, eventId); } /** * [ZH] * --- * 删除超级群所有频道指定时间之前的消息 * @param targetId 会话 ID * @param timestamp 时间戳 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete messages in all channels of an ultra group before a * specified timestamp. * @param targetId The conversation ID. * @param timestamp The timestamp. * @param callback The event callback. The SDK supports callback mode starting * from version 5.3.1. Other callback methods for this * interface are deprecated in version 5.4.0 and will be * removed in version 6.x. If the callback parameter is * provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. A non-zero value indicates that the current * interface call failed, and no interface callback will be triggered. * For detailed errors, refer to the error codes. * --- */ clearUltraGroupMessagesForAllChannel( targetId: string, timestamp: number, callback?: IRCIMIWClearUltraGroupMessagesForAllChannelCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessagesClearedForAllChannel } = callback; if (onUltraGroupMessagesClearedForAllChannel) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearUltraGroupMessagesForAllChannel:onUltraGroupMessagesClearedForAllChannel', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessagesClearedForAllChannel && onUltraGroupMessagesClearedForAllChannel(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearUltraGroupMessagesForAllChannel', { targetId, timestamp, callback, eventId }); return RCReactNativeIM.clearUltraGroupMessagesForAllChannel(targetId, timestamp, eventId); } /** * [ZH] * --- * 从服务获取批量消息 * @param messages 获取的消息集合 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve Batch Messages from Service * @param messages The collection of messages retrieved. * @param callback The event callback. Starting from SDK version 5.3.1, callback * is supported. Other callback methods for this interface are * deprecated as of version 5.4.0 and are expected to be removed * in version 6.x. If the callback parameter is provided, only * the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero values indicate that the current * operation failed, and no interface callback will be triggered. For * detailed error information, refer to the error codes. * --- */ getBatchRemoteUltraGroupMessages( messages: Array, callback?: IRCIMIWGetBatchRemoteUltraGroupMessagesCallback, ): Promise { if (messages) { messages = messages.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBatchRemoteUltraGroupMessages:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.matchedMessages, data?.notMatchedMessages); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetBatchRemoteUltraGroupMessages:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getBatchRemoteUltraGroupMessages', { messages, callback, eventId }); return RCReactNativeIM.getBatchRemoteUltraGroupMessages(messages, eventId); } /** * [ZH] * --- * 更新超级群消息扩展信息 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值 * @param expansion 更新的消息扩展信息键值对,类型是 HashMap;Key 支持大小写英文字母、数字、部分特殊符号 + = - _ * 的组合方式,不支持汉字。Value 可以输入空格。 * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Update Ultra Group Message Extension Information * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param expansion The key-value pairs for the updated message extension * information, of type HashMap. Key supports a combination of * uppercase and lowercase English letters, numbers, and * special characters + = - _. Chinese characters are not * supported. Value can include spaces. * @param callback The event callback. SDK supports callback method starting * from version 5.3.1. Other callback methods for this * interface are deprecated starting from version 5.4.0 and * are expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code for the current interface operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero indicates a failure in the current * interface call operation, and the interface callback will not be * triggered. Refer to the error codes for detailed errors. * --- */ updateUltraGroupMessageExpansion( messageUId: string, expansion: Map, callback?: IRCIMIWUpdateUltraGroupMessageExpansionCallback, ): Promise { let _expansion: any = Object.fromEntries(expansion); const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessageExpansionUpdated } = callback; if (onUltraGroupMessageExpansionUpdated) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'UpdateUltraGroupMessageExpansion:onUltraGroupMessageExpansionUpdated', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessageExpansionUpdated && onUltraGroupMessageExpansionUpdated(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('updateUltraGroupMessageExpansion', { messageUId, expansion, callback, eventId }); return RCReactNativeIM.updateUltraGroupMessageExpansion(messageUId, _expansion, eventId); } /** * [ZH] * --- * 删除超级群消息扩展信息中特定的键值对 * @param messageUId 消息的 messageUid,可在消息对象中获取,且只有发送成功的消息才会有值 * @param keys 消息扩展信息中待删除的 key 的列表,类型是 ArrayList * @param callback 事件回调。SDK 从 5.3.1 版本开始支持 callback 方式回调。从 5.4.0 * 版本废弃该接口的其他回调方式,预计将在 6.x 版本删除此其他回调方式。如果传入了 callback 参数,仅触发 * callback 回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Delete specific key-value pairs from the message extension * information of an ultra group. * @param messageUId The messageUid of the message, which can be obtained from * the message object. Only successfully sent messages will * have a value. * @param keys The list of keys to be deleted from the message extension * information, of type ArrayList. * @param callback Event callback. The SDK supports callback-based responses * starting from version 5.3.1. Other callback methods for * this interface are deprecated as of version 5.4.0 and are * expected to be removed in version 6.x. If the callback * parameter is provided, only the callback will be triggered. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. For detailed errors, refer to the error codes. * --- */ removeUltraGroupMessageExpansionForKeys( messageUId: string, keys: Array, callback?: IRCIMIWRemoveUltraGroupMessageExpansionForKeysCallback, ): Promise { if (keys) { keys = keys.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onUltraGroupMessageExpansionForKeysRemoved } = callback; if (onUltraGroupMessageExpansionForKeysRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveUltraGroupMessageExpansionForKeys:onUltraGroupMessageExpansionForKeysRemoved', (data: any) => { if (data?.eventId === eventId) { onUltraGroupMessageExpansionForKeysRemoved && onUltraGroupMessageExpansionForKeysRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeUltraGroupMessageExpansionForKeys', { messageUId, keys, callback, eventId }); return RCReactNativeIM.removeUltraGroupMessageExpansionForKeys(messageUId, keys, eventId); } /** * [ZH] * --- * 修改日志等级 * @param level 日志级别 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Modify Log Level * @param level The log level * @return The status code of the current operation. 0 indicates success, and * the specific result requires the implementation of the callback * interface. Non-zero indicates that the current operation failed, and * the callback interface will not be triggered. Refer to the error * codes for detailed error information. * --- */ changeLogLevel(level: RCIMIWLogLevel): Promise { logger.logObject('changeLogLevel', { level }); return RCReactNativeIM.changeLogLevel(level); } /** * [ZH] * --- * 获取本地时间与服务器时间的时间差。消息发送成功后,SDK 与服务器同步时间,消息所在数据库中存储的时间就是服务器时间。 * System.currentTimeMillis() - getDeltaTime() 可以获取服务器当前时间。 * @return 本地时间与服务器时间的差值 * --- * [EN] * --- * Retrieves the time difference between local time and server time. * After a message is successfully sent, the SDK synchronizes time with * the server, * and the time stored in the message database is the server time. * System.currentTimeMillis() - getDeltaTime() can be used to obtain the * current server time. * @return The time difference between local time and server time. * --- */ getDeltaTime(): Promise { logger.logObject('getDeltaTime', {}); return RCReactNativeIM.getDeltaTime(); } /** * 获取 AppKey 对应的配置。 * Get app settings for current AppKey. */ getAppSettings(): Promise { logger.logObject('getAppSettings', {}); return RCReactNativeIM.getAppSettings(); } /** * [ZH] * --- * 创建标签信息 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param tagName 长度不超过 15 个字,标签名称可以重复。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Create Tag Information * @param tagId The unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param tagName The name of the tag, with a maximum length of 15 characters. * Tag names can be duplicated. * @param callback Event callback. * @return The status code of the current API operation. 0 indicates a * successful call, and the specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current API * call operation failed, and the interface callback will not be * triggered. Refer to the error codes for detailed error information. * --- */ createTag(tagId: string, tagName: string, callback?: IRCIMIWCreateTagCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onTagCreated } = callback; if (onTagCreated) { const eventEmitter = RCReactNativeEventEmitter.addListener('CreateTag:onTagCreated', (data: any) => { if (data?.eventId === eventId) { onTagCreated && onTagCreated(data?.code); eventEmitter.remove(); } }); } } logger.logObject('createTag', { tagId, tagName, callback, eventId }); return RCReactNativeIM.createTag(tagId, tagName, eventId); } /** * [ZH] * --- * 移除标签 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove Tag * @param tagId The unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param callback The event callback. * @return The status code of the current operation. 0 indicates success, and * the specific result needs to be implemented in the interface * callback. Non-zero indicates that the current operation failed, and * the interface callback will not be triggered. For detailed errors, * refer to the error codes. * --- */ removeTag(tagId: string, callback?: IRCIMIWRemoveTagCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onTagRemoved } = callback; if (onTagRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener('RemoveTag:onTagRemoved', (data: any) => { if (data?.eventId === eventId) { onTagRemoved && onTagRemoved(data?.code); eventEmitter.remove(); } }); } } logger.logObject('removeTag', { tagId, callback, eventId }); return RCReactNativeIM.removeTag(tagId, eventId); } /** * [ZH] * --- * 更新标签信息 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param newName 长度不超过 15 个字,标签名称可以重复。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Update Tag Information * @param tagId The unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param newName The new name of the tag, with a maximum length of 15 * characters. Tag names can be duplicated. * @param callback The event callback. * @return The status code of the current operation. 0 indicates success, and * the specific result needs to be implemented in the callback. Non-zero * indicates failure, and the callback will not be triggered. Refer to * the error codes for detailed error information. * --- */ updateTagNameById(tagId: string, newName: string, callback?: IRCIMIWUpdateTagNameByIdCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onTagNameByIdUpdated } = callback; if (onTagNameByIdUpdated) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'UpdateTagNameById:onTagNameByIdUpdated', (data: any) => { if (data?.eventId === eventId) { onTagNameByIdUpdated && onTagNameByIdUpdated(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('updateTagNameById', { tagId, newName, callback, eventId }); return RCReactNativeIM.updateTagNameById(tagId, newName, eventId); } /** * [ZH] * --- * 获取当前用户已创建的标签信息 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the tag information created by the current user. * @param callback The event callback. * @return The status code of the current API operation. 0 indicates the call * was successful. Specific results need to be implemented in the * interface callback. Non-zero values indicate the current API call * failed, and the interface callback will not be triggered. For * detailed error information, refer to the error codes. * --- */ getTags(callback?: IRCIMIWGetTagsCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetTags:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener('GetTags:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }); } } logger.logObject('getTags', { callback, eventId }); return RCReactNativeIM.getTags(eventId); } /** * [ZH] * --- * 将一个会话添加到指定标签 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param type 会话类型 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Add a conversation to a specified tag * @param tagId The unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param type The type of the conversation * @param targetId The ID of the conversation * @param callback The event callback. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current operation * failed, and the interface callback will not be triggered. For * detailed error information, refer to the error codes. * --- */ addConversationToTag( tagId: string, type: RCIMIWConversationType, targetId: string, callback?: IRCIMIWAddConversationToTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationToTagAdded } = callback; if (onConversationToTagAdded) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'AddConversationToTag:onConversationToTagAdded', (data: any) => { if (data?.eventId === eventId) { onConversationToTagAdded && onConversationToTagAdded(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('addConversationToTag', { tagId, type, targetId, callback, eventId }); return RCReactNativeIM.addConversationToTag(tagId, type, targetId, eventId); } /** * [ZH] * --- * 从标签中移除一个会话 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param type 会话类型 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove a conversation from a tag * @param tagId Unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param type Conversation type * @param targetId Conversation ID * @param callback Event callback. * @return Status code of the current operation. 0 indicates success, and the * specific result needs to be implemented in the callback. Non-zero * indicates failure, and the callback will not be triggered. Refer to * the error codes for detailed error information. * --- */ removeConversationFromTag( tagId: string, type: RCIMIWConversationType, targetId: string, callback?: IRCIMIWRemoveConversationFromTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationFromTagRemoved } = callback; if (onConversationFromTagRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveConversationFromTag:onConversationFromTagRemoved', (data: any) => { if (data?.eventId === eventId) { onConversationFromTagRemoved && onConversationFromTagRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeConversationFromTag', { tagId, type, targetId, callback, eventId }); return RCReactNativeIM.removeConversationFromTag(tagId, type, targetId, eventId); } /** * [ZH] * --- * 为指定会话移除一个或多个标签 * @param type 会话类型 * @param targetId 会话 ID * @param tagIds 标签集合 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove one or more tags for a specified conversation * @param type Specifies the conversation type * @param targetId Indicates the conversation ID * @param tagIds Represents the collection of tags * @param callback Specifies the event callback. * @return Returns the status code of the current operation. 0 indicates * success, and the specific result requires implementing the callback * interface. Non-zero values indicate failure of the current operation, * and the callback will not be triggered. Refer to the error codes for * detailed error information. * --- */ removeTagsFromConversation( type: RCIMIWConversationType, targetId: string, tagIds: Array, callback?: IRCIMIWRemoveTagsFromConversationCallback, ): Promise { if (tagIds) { tagIds = tagIds.filter((v) => v != null && v != undefined); } const eventId = Math.random().toString(); if (callback) { const { onTagsFromConversationRemoved } = callback; if (onTagsFromConversationRemoved) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'RemoveTagsFromConversation:onTagsFromConversationRemoved', (data: any) => { if (data?.eventId === eventId) { onTagsFromConversationRemoved && onTagsFromConversationRemoved(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('removeTagsFromConversation', { type, targetId, tagIds, callback, eventId }); return RCReactNativeIM.removeTagsFromConversation(type, targetId, tagIds, eventId); } /** * [ZH] * --- * 获取指定会话携带的所有标签 * @param type 会话类型 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * ### Get All Tags Associated with a Specified Conversation * @param type Specifies the conversation type. * @param targetId Indicates the conversation ID. * @param callback Represents the event callback. * @return Returns the status code of the current operation. `0` indicates a * successful call, and the specific result needs to be handled in the * callback. Non-zero values indicate that the operation failed, and the * callback will not be triggered. Refer to the error codes for detailed * error information. * --- */ getTagsFromConversation( type: RCIMIWConversationType, targetId: string, callback?: IRCIMIWGetTagsFromConversationCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTagsFromConversation:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetTagsFromConversation:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getTagsFromConversation', { type, targetId, callback, eventId }); return RCReactNativeIM.getTagsFromConversation(type, targetId, eventId); } /** * [ZH] * --- * 以会话中最后一条消息时间戳为界,分页获取本地指定标签下会话列表 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param timestamp 会话的时间戳。获取这个时间戳之前的会话列表。首次可传 0,后续可以使用返回的 RCConversation 对象的 * operationTime 属性值,作为下一次查询的 startTime。 * @param count 获取的数量。当实际取回的会话数量小于 count 值时,表明已取完数据。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Retrieve the local conversation list under a specified tag, paginated * by the timestamp of the last message in the conversation. * @param tagId The unique identifier of the tag, a string type with a * maximum length of 10 characters. * @param timestamp The timestamp of the conversation. Retrieves the * conversation list before this timestamp. For the first * query, pass 0. For subsequent queries, use the operationTime * property value from the returned RCConversation object as * the startTime for the next query. * @param count The number of conversations to retrieve. If the number of * conversations retrieved is less than the count value, it * indicates that all data has been fetched. * @param callback The event callback. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented in the * interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. Refer to the error codes for detailed error information. * --- */ getConversationsFromTagByPage( tagId: string, timestamp: number, count: number, callback?: IRCIMIWGetConversationsCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsFromTagByPage:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationsFromTagByPage:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationsFromTagByPage', { tagId, timestamp, count, callback, eventId }); return RCReactNativeIM.getConversationsFromTagByPage(tagId, timestamp, count, eventId); } /** * [ZH] * --- * 获取携带指定标签的所有会话的未读消息数。 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param contain 是否包含免打扰会话。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Get the unread message count for all conversations with the specified * tag. * @param tagId The unique identifier of the tag. It is a string type and its * length should not exceed 10 characters. * @param contain Indicates whether to include conversations with Do Not * Disturb enabled. * @param callback The event callback. * @return The status code of the current API operation. 0 indicates that the * call was successful. The specific result needs to be implemented in * the interface callback. Non-zero values indicate that the current API * call operation failed, and the interface callback will not be * triggered. For detailed errors, refer to the error codes. * --- */ getUnreadCountByTag(tagId: string, contain: boolean, callback?: IRCIMIWGetUnreadCountCallback): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByTag:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetUnreadCountByTag:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getUnreadCountByTag', { tagId, contain, callback, eventId }); return RCReactNativeIM.getUnreadCountByTag(tagId, contain, eventId); } /** * [ZH] * --- * 在携带指定标签的所有会话中设置指定会话置顶。例如,在所有添加了「培训班」标签的会话中将与「Tom」的私聊会话置顶。 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param type 会话类型 * @param targetId 会话 ID * @param top 是否置顶 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Set the specified conversation as top in all conversations with the * specified tag. For example, pin the private chat with "Tom" to the * top among all conversations tagged with "Training Class". * @param tagId The unique identifier of the tag, character type, with a * maximum length of 10 characters. * @param type The type of conversation. * @param targetId The ID of the conversation. * @param top Whether to pin the conversation to the top. * @param callback The event callback. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be handled in the callback. * Non-zero indicates a failed operation, and the callback will not be * triggered. Refer to the error codes for detailed error information. * --- */ changeConversationTopStatusInTag( tagId: string, type: RCIMIWConversationType, targetId: string, top: boolean, callback?: IRCIMIWChangeConversationTopStatusInTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onConversationTopStatusInTagChanged } = callback; if (onConversationTopStatusInTagChanged) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ChangeConversationTopStatusInTag:onConversationTopStatusInTagChanged', (data: any) => { if (data?.eventId === eventId) { onConversationTopStatusInTagChanged && onConversationTopStatusInTagChanged(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('changeConversationTopStatusInTag', { tagId, type, targetId, top, callback, eventId }); return RCReactNativeIM.changeConversationTopStatusInTag(tagId, type, targetId, top, eventId); } /** * [ZH] * --- * 查询指定会话是否在携带同一标签的所有会话中置顶。获取成功后会返回是否已置顶。 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param type 会话类型 * @param targetId 会话 ID * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Checks whether the specified conversation is pinned among all * conversations with the same tag. Returns the pinned status upon * successful retrieval. * @param tagId The unique identifier of the tag. String type, with a maximum * length of 10 characters. * @param type The type of the conversation. * @param targetId The ID of the conversation. * @param callback The event callback. * @return The status code of the current operation. 0 indicates success, and * the detailed result needs to be handled in the callback. Non-zero * values indicate failure, and no callback will be triggered. Refer to * the error codes for detailed error information. * --- */ getConversationTopStatusInTag( tagId: string, type: RCIMIWConversationType, targetId: string, callback?: IRCIMIWGetConversationTopStatusInTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTopStatusInTag:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'GetConversationTopStatusInTag:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('getConversationTopStatusInTag', { tagId, type, targetId, callback, eventId }); return RCReactNativeIM.getConversationTopStatusInTag(tagId, type, targetId, eventId); } /** * [ZH] * --- * 清除携带指定标签的所有会话的未读消息数。 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Clear the unread message count for all conversations carrying the * specified tag. * @param tagId The unique identifier of the tag, string type, with a maximum * length of 10 characters. * @param callback The event callback. * @return The status code of the current operation. 0 indicates a successful * call, and the specific result needs to be implemented through the * interface callback. Non-zero indicates that the current interface * call operation failed, and the interface callback will not be * triggered. For detailed errors, refer to the error codes. * --- */ clearMessagesUnreadStatusByTag( tagId: string, callback?: IRCIMIWClearMessagesUnreadStatusByTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearMessagesUnreadStatusByTag:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearMessagesUnreadStatusByTag:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearMessagesUnreadStatusByTag', { tagId, callback, eventId }); return RCReactNativeIM.clearMessagesUnreadStatusByTag(tagId, eventId); } /** * [ZH] * --- * 删除指定标签下的全部会话,同时解除这些会话和标签的绑定关系。删除成功后,会话不再携带指定的标签。这些会话收到新消息时,会产生新的会话。 * @param tagId 标签唯一标识,字符型,长度不超过 10 个字。 * @param deleteMessage 是否删除消息 * @param callback 事件回调。 * @return 当次接口操作的状态码。0 代表调用成功 具体结果需要实现接口回调,非 0 代表当前接口调用操作失败,不会触发接口回调,详细错误参考错误码 * --- * [EN] * --- * Remove all conversations under the specified tag and unbind these * conversations from the tag. After successful deletion, the * conversations will no longer carry the specified tag. When these * conversations receive new messages, new conversations will be * created. * @param tagId The unique identifier of the tag, character type, with a * length not exceeding 10 characters. * @param deleteMessage Specifies whether to delete the messages. * @param callback Event callback. * @return The status code of the current API operation. 0 indicates a * successful call, and the specific result needs to be implemented via * the interface callback. Non-zero indicates that the current API call * failed, and the interface callback will not be triggered. For * detailed errors, refer to the error codes. * --- */ clearConversationsByTag( tagId: string, deleteMessage: boolean, callback?: IRCIMIWClearConversationsByTagCallback, ): Promise { const eventId = Math.random().toString(); if (callback) { const { onSuccess, onError } = callback; if (onSuccess) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearConversationsByTag:onSuccess', (data: any) => { if (data?.eventId === eventId) { onSuccess && onSuccess(data?.t); eventEmitter.remove(); } }, ); } if (onError) { const eventEmitter = RCReactNativeEventEmitter.addListener( 'ClearConversationsByTag:onError', (data: any) => { if (data?.eventId === eventId) { onError && onError(data?.code); eventEmitter.remove(); } }, ); } } logger.logObject('clearConversationsByTag', { tagId, deleteMessage, callback, eventId }); return RCReactNativeIM.clearConversationsByTag(tagId, deleteMessage, eventId); } /** * [ZH] * --- * 设置是否检查聊天室重复消息的方法。 * 可以通过实现此方法来控制聊天室中是否需要对重复消息进行检查,以防止相同消息的重复显示或处理。 * @param enableCheck 默认是true; true表示开启检查聊天室中重复消息的功能,false表示关闭检查聊天室中重复消息的功能。 * --- * [EN] * --- * Control chatroom duplicate message check * @param enableCheck Defaults to true. Set true to enable duplicate message * check, false to disable it * --- */ setCheckChatRoomDuplicateMessage(enableCheck: boolean): Promise { logger.logObject('setCheckChatRoomDuplicateMessage', { enableCheck }); return RCReactNativeIM.setCheckChatRoomDuplicateMessage(enableCheck); } /** * [ZH] * --- * 收到消息的监听 * @param message 接收到的消息对象 * @param left 当客户端连接成功后,服务端会将所有补偿消息以消息包的形式下发给客户端,最多每 200 条消息为一个消息包,即一个 Package, 客户端接受到消息包后,会逐条解析并通知应用。left 为当前消息包(Package)里还剩余的消息条数 * @param offline 消息是否离线消息 * @param hasPackage 是否在服务端还存在未下发的消息包 * --- * [EN] * --- * Message Received Listener * @param message Represents the received message object. * @param left After the client successfully connects, the server delivers all compensation messages in packages, with a maximum of 200 messages per package. Once the client receives a message package, it parses and notifies the application message by message. The `left` parameter indicates the number of remaining messages in the current package. * @param offline Specifies whether the message is an offline message. * @param hasPackage Indicates whether there are undelivered message packages remaining on the server. * --- */ setOnMessageReceivedListener( listener?: (message: RCIMIWMessage, left: number, offline: boolean, hasPackage: boolean) => void, ): void { const eventName = 'IRCIMIWListener:onMessageReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { message: RCIMIWMessage; left: number; offline: boolean; hasPackage: boolean }) => { logger.logObject('onMessageReceived', data); listener(data.message, data.left, data.offline, data.hasPackage); }, ); } } /** * [ZH] * --- * 离线消息同步完成 * --- * [EN] * --- * Offline messages synced * --- */ setOnOfflineMessageSyncCompletedListener(listener?: () => void): void { const eventName = 'IRCIMIWListener:onOfflineMessageSyncCompleted'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, () => { logger.logObject('onOfflineMessageSyncCompleted', {}); listener(); }); } } /** * [ZH] * --- * 网络状态变化 * @param status SDK 与融云服务器的连接状态 * --- * [EN] * --- * Network Status Change * @param status Specifies the connection status between the SDK and the RongCloud server. * --- */ setOnConnectionStatusChangedListener(listener?: (status: RCIMIWConnectionStatus) => void): void { const eventName = 'IRCIMIWListener:onConnectionStatusChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { status: RCIMIWConnectionStatus }) => { logger.logObject('onConnectionStatusChanged', data); listener(data.status); }); } } /** * [ZH] * --- * 会话状态置顶多端同步监听 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param top 是否置顶 * --- * [EN] * --- * Pin Conversation Status Multi-Device Sync Listener * @param type Specifies the conversation type. * @param targetId Indicates the conversation ID. * @param channelId Represents the channel ID, which is only supported for ultra groups. For other conversation types, pass `null`. * @param top Indicates whether the conversation is pinned. * --- */ setOnConversationTopStatusSyncedListener( listener?: (type: RCIMIWConversationType, targetId: string, channelId: string, top: boolean) => void, ): void { const eventName = 'IRCIMIWListener:onConversationTopStatusSynced'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { type: RCIMIWConversationType; targetId: string; channelId: string; top: boolean }) => { logger.logObject('onConversationTopStatusSynced', data); listener(data.type, data.targetId, data.channelId, data.top); }, ); } } /** * [ZH] * --- * 会话状态免打扰多端同步监听 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param level 当前会话通知的类型 * --- * [EN] * --- * Conversation Status Do Not Disturb Multi-Device Synchronization Listener * @param type Specifies the conversation type * @param targetId Specifies the conversation ID * @param channelId Specifies the channel ID, supported only for ultra groups. For other conversation types, pass `null`. * @param level Indicates the current notification type for the conversation * --- */ setOnConversationNotificationLevelSyncedListener( listener?: ( type: RCIMIWConversationType, targetId: string, channelId: string, level: RCIMIWPushNotificationLevel, ) => void, ): void { const eventName = 'IRCIMIWListener:onConversationNotificationLevelSynced'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { type: RCIMIWConversationType; targetId: string; channelId: string; level: RCIMIWPushNotificationLevel; }) => { logger.logObject('onConversationNotificationLevelSynced', data); listener(data.type, data.targetId, data.channelId, data.level); }, ); } } /** * [ZH] * --- * 撤回消息监听器 * @param message 原本的消息会变为撤回消息 * --- * [EN] * --- * Message Recall Listener * @param message The original message will be transformed into a recalled message. * --- */ setOnRemoteMessageRecalledListener(listener?: (message: RCIMIWMessage) => void): void { const eventName = 'IRCIMIWListener:onRemoteMessageRecalled'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { message: RCIMIWMessage }) => { logger.logObject('onRemoteMessageRecalled', data); listener(data.message); }); } } /** * [ZH] * --- * 单聊中收到消息回执的回调。 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp 已阅读的最后一条消息的 sendTime * --- * [EN] * --- * Callback triggered when a message receipt is received in a one-to-one chat. * @param targetId The conversation ID * @param channelId The channel ID, only supported for ultra groups. Pass `null` for other conversation types. * @param timestamp The sendTime of the last read message * --- */ setOnPrivateReadReceiptReceivedListener( listener?: (targetId: string, channelId: string, timestamp: number) => void, ): void { const eventName = 'IRCIMIWListener:onPrivateReadReceiptReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { targetId: string; channelId: string; timestamp: number }) => { logger.logObject('onPrivateReadReceiptReceived', data); listener(data.targetId, data.channelId, data.timestamp); }, ); } } /** * [ZH] * --- * 消息扩展信息更改的回调 * @param expansion 消息扩展信息中更新的键值对,只包含更新的键值对,不是全部的数据。如果想获取全部的键值对,请使用 message 的 expansion 属性。 * @param message 发生变化的消息 * --- * [EN] * --- * Callback for Message Extension Information Change * @param expansion Specifies the key-value pairs updated in the message extension information. Only the updated key-value pairs are included, not the entire dataset. To retrieve all key-value pairs, use the `expansion` property of the `message` object. * @param message Indicates the message object where the changes occurred. * --- */ setOnRemoteMessageExpansionUpdatedListener( listener?: (expansion: Map, message: RCIMIWMessage) => void, ): void { const eventName = 'IRCIMIWListener:onRemoteMessageExpansionUpdated'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { expansion: any; message: RCIMIWMessage }) => { logger.logObject('onRemoteMessageExpansionUpdated', data); let _expansion = new Map(Object.entries(data.expansion)); listener(_expansion, data.message); }); } } /** * [ZH] * --- * 消息扩展信息删除的回调 * @param message 发生变化的消息 * @param keys 消息扩展信息中删除的键值对 key 列表 * --- * [EN] * --- * Callback for Message Extension Information Deletion * @param message The message that has been modified * @param keys List of keys deleted from the message extension information * --- */ setOnRemoteMessageExpansionForKeyRemovedListener( listener?: (message: RCIMIWMessage, keys: Array) => void, ): void { const eventName = 'IRCIMIWListener:onRemoteMessageExpansionForKeyRemoved'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { message: RCIMIWMessage; keys: Array }) => { logger.logObject('onRemoteMessageExpansionForKeyRemoved', data); listener(data.message, data.keys); }, ); } } /** * [ZH] * --- * 聊天室用户进入、退出聊天室监听 * @param targetId 会话 ID * @param actions 发生的事件 * --- * [EN] * --- * Chatroom User Entry and Exit Monitoring * @param targetId Conversation ID * @param actions Events that occurred * --- */ setOnChatRoomMemberChangedListener( listener?: (targetId: string, actions: Array) => void, ): void { const eventName = 'IRCIMIWListener:onChatRoomMemberChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { targetId: string; actions: Array }) => { logger.logObject('onChatRoomMemberChanged', data); listener(data.targetId, data.actions); }, ); } } /** * [ZH] * --- * 会话输入状态发生变化。对于单聊而言,当对方正在输入时,监听会触发一次;当对方不处于输入状态时,该监听还会触发一次,但回调里输入用户列表为空。 * @param type 会话类型 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param userTypingStatus 发生状态变化的集合 * --- * [EN] * --- * The conversation input status has changed. For one-to-one chats, the listener is triggered once when the other party is typing, and it is triggered again when the other party stops typing, but the list of typing users in the callback will be empty. * @param type Conversation type * @param targetId Conversation ID * @param channelId Channel ID, only supported for ultra groups. For other conversation types, pass null. * @param userTypingStatus Collection of users whose typing status has changed * --- */ setOnTypingStatusChangedListener( listener?: ( type: RCIMIWConversationType, targetId: string, channelId: string, userTypingStatus: Array, ) => void, ): void { const eventName = 'IRCIMIWListener:onTypingStatusChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { type: RCIMIWConversationType; targetId: string; channelId: string; userTypingStatus: Array; }) => { logger.logObject('onTypingStatusChanged', data); listener(data.type, data.targetId, data.channelId, data.userTypingStatus); }, ); } } /** * [ZH] * --- * 同步消息未读状态监听接口。多端登录,收到其它端清除某一会话未读数通知的时候 * @param type 会话类型 * @param targetId 会话 ID * @param timestamp 时间戳 * --- * [EN] * --- * Listener interface for synchronizing unread message status. Triggers when a multi-device login occurs and a notification is received from another device clearing the unread count of a specific conversation. * @param type Conversation type * @param targetId Conversation ID * @param timestamp Timestamp * --- */ setOnConversationReadStatusSyncMessageReceivedListener( listener?: (type: RCIMIWConversationType, targetId: string, timestamp: number) => void, ): void { const eventName = 'IRCIMIWListener:onConversationReadStatusSyncMessageReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { type: RCIMIWConversationType; targetId: string; timestamp: number }) => { logger.logObject('onConversationReadStatusSyncMessageReceived', data); listener(data.type, data.targetId, data.timestamp); }, ); } } /** * [ZH] * --- * 聊天室 KV 同步完成的回调 * @param roomId 聊天室 ID * --- * [EN] * --- * Chatroom KV Synchronization Completion Callback * @param roomId The ID of the chatroom. * --- */ setOnChatRoomEntriesSyncedListener(listener?: (roomId: string) => void): void { const eventName = 'IRCIMIWListener:onChatRoomEntriesSynced'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { roomId: string }) => { logger.logObject('onChatRoomEntriesSynced', data); listener(data.roomId); }); } } /** * [ZH] * --- * 聊天室 KV 发生变化的回调 * @param operationType 操作的类型 * @param roomId 聊天室 ID * @param entries 发送变化的 KV * --- * [EN] * --- * Callback for Chatroom KV Changes * @param operationType Specifies the type of operation * @param roomId Indicates the chatroom ID * @param entries Represents the KV that has changed * --- */ setOnChatRoomEntriesChangedListener( listener?: ( operationType: RCIMIWChatRoomEntriesOperationType, roomId: string, entries: Map, ) => void, ): void { const eventName = 'IRCIMIWListener:onChatRoomEntriesChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { operationType: RCIMIWChatRoomEntriesOperationType; roomId: string; entries: any }) => { logger.logObject('onChatRoomEntriesChanged', data); let _entries = new Map(Object.entries(data.entries)); listener(data.operationType, data.roomId, _entries); }, ); } } /** * [ZH] * --- * 超级群消息 kv 被更新 * @param messages 被更新的消息集合 * --- * [EN] * --- * Supergroup message KV is updated. * @param messages The collection of messages that have been updated. * --- */ setOnRemoteUltraGroupMessageExpansionUpdatedListener(listener?: (messages: Array) => void): void { const eventName = 'IRCIMIWListener:onRemoteUltraGroupMessageExpansionUpdated'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { messages: Array }) => { logger.logObject('onRemoteUltraGroupMessageExpansionUpdated', data); listener(data.messages); }); } } /** * [ZH] * --- * 超级群消息被更改 * @param messages 被更新的消息集合 * --- * [EN] * --- * Super Group Messages Updated * @param messages Specifies the collection of updated messages. * --- */ setOnRemoteUltraGroupMessageModifiedListener(listener?: (messages: Array) => void): void { const eventName = 'IRCIMIWListener:onRemoteUltraGroupMessageModified'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { messages: Array }) => { logger.logObject('onRemoteUltraGroupMessageModified', data); listener(data.messages); }); } } /** * [ZH] * --- * 超级群消息被撤回 * @param messages 撤回的消息集合 * --- * [EN] * --- * Ultra Group Message Recalled * @param messages Specifies the collection of messages that have been recalled. * --- */ setOnRemoteUltraGroupMessageRecalledListener(listener?: (messages: Array) => void): void { const eventName = 'IRCIMIWListener:onRemoteUltraGroupMessageRecalled'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { messages: Array }) => { logger.logObject('onRemoteUltraGroupMessageRecalled', data); listener(data.messages); }); } } /** * [ZH] * --- * 超级群已读的监听 * @param targetId 会话 ID * @param channelId 频道 ID,仅支持超级群使用,其他会话类型传 null 即可。 * @param timestamp * --- * [EN] * --- * Ultra Group Read Receipt Listener * @param targetId Conversation ID * @param channelId Channel ID (supported only for ultra groups; for other conversation types, pass `null`). * @param timestamp Indicates the timestamp of the read receipt. * --- */ setOnUltraGroupReadTimeReceivedListener( listener?: (targetId: string, channelId: string, timestamp: number) => void, ): void { const eventName = 'IRCIMIWListener:onUltraGroupReadTimeReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { targetId: string; channelId: string; timestamp: number }) => { logger.logObject('onUltraGroupReadTimeReceived', data); listener(data.targetId, data.channelId, data.timestamp); }, ); } } /** * [ZH] * --- * 用户输入状态变化的回调 * 当客户端收到用户输入状态的变化时,会回调此接口,通知发生变化的会话以及当前正在输入的RCUltraGroupTypingStatusInfo列表 * @param info 正在输入的RCUltraGroupTypingStatusInfo列表(nil标示当前没有用户正在输入) * --- * [EN] * --- * Callback for User Typing Status Change * This callback is triggered when the client detects a change in the user's typing status. It notifies the affected conversation and provides a list of RCUltraGroupTypingStatusInfo indicating users currently typing. * @param info List of RCUltraGroupTypingStatusInfo indicating users currently typing (nil indicates no users are currently typing) * --- */ setOnUltraGroupTypingStatusChangedListener( listener?: (info: Array) => void, ): void { const eventName = 'IRCIMIWListener:onUltraGroupTypingStatusChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { info: Array }) => { logger.logObject('onUltraGroupTypingStatusChanged', data); listener(data.info); }, ); } } /** * [ZH] * --- * 发送含有敏感词消息被拦截的回调 * @param info 被拦截消息的相关信息 * --- * [EN] * --- * Callback for Blocked Messages Containing Sensitive Words * @param info Specifies the details of the blocked message. * --- */ setOnMessageBlockedListener(listener?: (info: RCIMIWBlockedMessageInfo) => void): void { const eventName = 'IRCIMIWListener:onMessageBlocked'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { info: RCIMIWBlockedMessageInfo }) => { logger.logObject('onMessageBlocked', data); listener(data.info); }); } } /** * [ZH] * --- * 聊天室状态发生变化的监听 * @param targetId 会话 ID * @param status 聊天室变化的状态 * --- * [EN] * --- * Callback for Chatroom Status Changes * @param targetId The conversation ID * @param status The status of the chatroom change * --- */ setOnChatRoomStatusChangedListener(listener?: (targetId: string, status: RCIMIWChatRoomStatus) => void): void { const eventName = 'IRCIMIWListener:onChatRoomStatusChanged'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { targetId: string; status: RCIMIWChatRoomStatus }) => { logger.logObject('onChatRoomStatusChanged', data); listener(data.targetId, data.status); }, ); } } /** * [ZH] * --- * 收到群聊已读回执请求的监听 * @param targetId 会话 ID * @param messageUId 消息的 messageUid * --- * [EN] * --- * Callback for Receiving Group Chat Read Receipt Request * @param targetId Conversation ID * @param messageUId Message's messageUid * --- */ setOnGroupMessageReadReceiptRequestReceivedListener( listener?: (targetId: string, messageUId: string) => void, ): void { const eventName = 'IRCIMIWListener:onGroupMessageReadReceiptRequestReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { targetId: string; messageUId: string }) => { logger.logObject('onGroupMessageReadReceiptRequestReceived', data); listener(data.targetId, data.messageUId); }); } } /** * [ZH] * --- * 收到群聊已读回执响应的监听 * @param targetId 会话 ID * @param messageUId 收到回执响应的消息的 messageUId * @param respondUserIds 会话中响应了此消息的用户列表。其中 key: 用户 id ; value: 响应时间。 * --- * [EN] * --- * Listener for Group Chat Read Receipt Response * @param targetId Conversation ID * @param messageUId Message UID of the message for which the read receipt response was received * @param respondUserIds List of users in the conversation who responded to this message. The key is the user ID, and the value is the response time. * --- */ setOnGroupMessageReadReceiptResponseReceivedListener( listener?: (targetId: string, messageUId: string, respondUserIds: Map) => void, ): void { const eventName = 'IRCIMIWListener:onGroupMessageReadReceiptResponseReceived'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener( eventName, (data: { targetId: string; messageUId: string; respondUserIds: any }) => { logger.logObject('onGroupMessageReadReceiptResponseReceived', data); let _respondUserIds = new Map(Object.entries(data.respondUserIds)); listener(data.targetId, data.messageUId, _respondUserIds); }, ); } } /** * [ZH] * --- * 超级群列表同步完成的回调 * --- * [EN] * --- * Callback for Ultra Group List Synchronization Completion * --- */ setOnUltraGroupConversationsSyncedListener(listener?: () => void): void { const eventName = 'IRCIMIWListener:onUltraGroupConversationsSynced'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, () => { logger.logObject('onUltraGroupConversationsSynced', {}); listener(); }); } } /** * [ZH] * --- * 远端会话列表同步完成的回调 * @param code 接口回调的状态码,0 代表成功,非 0 代表出现异常 * --- * [EN] * --- * Callback when remote conversation list sync completes * @param code Status code of the sync result. 0 indicates success, non-zero indicates failure. * --- */ setOnRemoteConversationListSyncedListener(listener?: (code: number) => void): void { const eventName = 'IRCIMIWListener:onRemoteConversationListSynced'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { code: number }) => { logger.logObject('onRemoteConversationListSynced', data); listener(data.code); }); } } /** * [ZH] * --- * 正在加入聊天室的回调 * @param targetId 聊天室 ID * --- * [EN] * --- * Callback for Joining a Chatroom * @param targetId Specifies the ID of the chatroom. * --- */ setOnChatRoomJoiningListener(listener?: (targetId: string) => void): void { const eventName = 'IRCIMIWListener:onChatRoomJoining'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { targetId: string }) => { logger.logObject('onChatRoomJoining', data); listener(data.targetId); }); } } /** * [ZH] * --- * 多端登录相关事件通知回调 * @param event 同步事件信息 * --- * [EN] * --- * Callback for multi-device login events * @param event Synchronization event details * --- */ setOnChatRoomNotifyMultiLoginSyncListener(listener?: (event: RCIMIWChatRoomSyncEvent) => void): void { const eventName = 'IRCIMIWListener:onChatRoomNotifyMultiLoginSync'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { event: RCIMIWChatRoomSyncEvent }) => { logger.logObject('onChatRoomNotifyMultiLoginSync', data); listener(data.event); }); } } /** * [ZH] * --- * 封禁用户相关事件通知回调 * @param event 封禁事件信息 * --- * [EN] * --- * Callback for banned user events * @param event Ban event details * --- */ setOnChatRoomNotifyBlockListener(listener?: (event: RCIMIWChatRoomMemberBlockEvent) => void): void { const eventName = 'IRCIMIWListener:onChatRoomNotifyBlock'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { event: RCIMIWChatRoomMemberBlockEvent }) => { logger.logObject('onChatRoomNotifyBlock', data); listener(data.event); }); } } /** * [ZH] * --- * 禁言相关事件通知回调 * @param event 禁言事件信息 * --- * [EN] * --- * Mute event notification callback * @param event Mute event details * --- */ setOnChatRoomNotifyBanListener(listener?: (event: RCIMIWChatRoomMemberBanEvent) => void): void { const eventName = 'IRCIMIWListener:onChatRoomNotifyBan'; RCReactNativeEventEmitter.removeAllListeners(eventName); if (listener) { RCReactNativeEventEmitter.addListener(eventName, (data: { event: RCIMIWChatRoomMemberBanEvent }) => { logger.logObject('onChatRoomNotifyBan', data); listener(data.event); }); } } }