Message Management
Global IM UIKit dynamically updates the message list and conversation list in the UI based on message sending and receiving. Therefore, when integrating Global IM UIKit, developers should note: Do not use the message sending function interfaces in IMLib; instead, use the message sending interfaces provided by Global IM UIKit to ensure that the SDK can correctly handle message states internally.
Limitations
Global IM UIKit currently has the following restrictions:
- The maximum size for images and files is 100 MB.
- The maximum size for GIF files is 2 MB. Files exceeding this limit will be sent as file messages.
- Supports sending short videos of up to 2 minutes.
Sending Messages
Generally, users can send various types of messages through the existing UI interface. When developers need to bypass the UI and send messages directly, Global IM UIKit provides the sendMessage
interface, which is fully consistent with the IMLib interface parameters. This interface can be used to send any type of message.
For example, to send a text message to user A using the sendMessage
interface, the sample code is as follows:
// Construct the target conversation, here using a group chat as an example
const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE, // Conversation type is one-to-one chat
targetId: 'A' // User A's ID
};
// Construct the text message
const message = new RongIMLib.TextMessage({ content: 'Hello' })
// Send the message. Note that the sendMessage interface provided by Global IM UIKit is used here.
const { code } = await kitApp.sendMessage(conversation, message);
For more detailed information on message-related content, please refer to the IMLib SDK Documentation · Sending Messages.
Inserting Messages
insertMessage is the message insertion interface provided by Global IM UIKit. You can use this interface to insert messages into the local message list.
Messages inserted locally only exist in the local cache: On the Web platform, since there is no persistent message storage locally, the messages will be lost after refreshing the page; on the Electron platform, the messages will be persisted to the local database.
Code Example
// Construct the target conversation, here using a group chat as an example
const conversation = {
conversationType: RongIMLib.ConversationType.PRIVATE, // Conversation type is one-to-one chat
targetId: 'A' // User A's ID
};
// Construct the text message
const message = new RongIMLib.TextMessage({ content: 'Hello' })
// Insert the message. Note that the insertMessage interface provided by Global IM UIKit is used here.
const { code } = await kitApp.insertMessage(conversation, message);