Update time: 2023/02/01 15:37:09
The in-session messages can only appear in the chat interface. You can send messages to another user in the app, or group chats and chat rooms. For example, text messages and image messages belong to in-session messages.
Session messages supported by the IM SDK include the following types:
|Messages that use plain text
|5,000 characters long.
|Image messages that contain information about image URLs, dimensions, and size.
|The content of a message is the URL of an audio file, duration, size, format and other information about an audio file
|You can record and upload an audio file using
AudioService. The default audio duration is 120 seconds (custom duration is supported), and the file size is unlimited. Set the size limit based on your business requirements.
|Video messages that contain information about video URLs, duration, size, and format.
|The file size and duration are unlimited. Set the limit based on your business requirements.
|Messages that contain information about file URLs, size, and format
|The file format is unlimited. The size for upload from the SDK is unlimited. The maximum size of upload files from the server is 15 MB. Implement limits based on your business scenario.
|Location messages that contain the geographic location title, longitude, and latitude.
|ip messages Not used for push notifications and notification bar reminders. Instead, tip messages can serve as in-session notification reminders, such as the welcome message that appears when joining a session, or the prompt message after hitting a sensitive word during the session.
|Notifications are sent for events of groups, chat rooms and supergroups. Notifications of this type are sent by the server, and clients cannot send notification messages. Notification messages are sent in online, offline and roaming modes. No alerts on the notification bar
|User-defined message type, such as red packets and rock paper scissor
The structure of a message body defined in the NIM SDK is
|Client ID of a message
|The server ID of a message
|The ID of a chat object (friend account or group ID).
|the account of a user that sends a message
|The session type, such as group chat
|The type of a client that sends a message
|The nickname of a user that sends a message (not supported on Windows and macOS)
|The subtype of a message
|The message direction that indicates whether a message is sent or received.
|Whether the sender is in the blocklist of a recipient.
|The message body. Except the content of a text message or alert message, other types of messages have an empty body.
|Time when a notification is sent in milliseconds.
|Attachment of a message. The field is valid if the
messageType is not
|Message attachment status (not supported by Windows and macOS)
|message configuration For more information, see
|The extension field (this field will be sent to the target client),
A maximum of 1024 characters are allowed.
Make sure the Map object can be converted to JSONObject.
|The local extension field of a message that is not sent to other clients. A maximum of 1024 characters are allowed.
Make sure the Map object can be converted to JSONObject.
|the custom extension field returned by a webhook.
|The body of a push notification.
|The payload object of a push notification.
|Options of force push notifications for group members
|Check whether the message sent by the current user is read.
|The content moderation options
|Whether a message is updated in a session.
In addition to rich message types, IM SDK also provides with support for common messages.
|Messages sent from others when a user is offline. Upon the next login, the offline messages temporarily stored during the offline period will be automatically delivered to the client SDK. In the private chat scenario, the most recent 5,000 offline messages in the last 30 days are loaded, and each session can load up to 100 recent offline messages; in the group chat scenario, the offline messages in the most recent 30 days are loaded, and each group chat session can load up to 100 recent offline messages.
|Automatically synchronize the roaming messages stored on the server when a new device logs in. The last 100 sessions within 7 days are synced, the last 100 messages per session are roamed
|When the same account logs in on multiple device at the same time, messages are sent to other devices in real time
|Supports local message history and cloud-based message history. The standard version allows you to obtain the cloud history messages last year, which can be extended to 3 years at most (add-on feature)
|Recall delivered messages. Messages delivered within 2 minutes can be recalled by default. The duration can be configured in the CommsEase console. You can only recall messages in P2P chat and group chats. Messages delivered in chat rooms cannot be recalled.
|Indicate the read and unread state of messages in group chat and P2P conversations
|Forward one or more messages to other users or groups
|Use the custom field to implement the @mention operation. When sending a group message by @mentioning someone, it can be delivered with a list of @mentioned accounts in the extension field.
If a group member receives a message, check whether the member is included in the list of @mentioned accounts in the extension field. If included, a reminder of being @mentioned will be indicated on the interface.
|The typing indicator can be implemented using a custom system notification. For more information, see: Custom system notification
Notifications and system notifications
Notification messages are
in-session messages that are delivered for online, offline, and roaming users. Notification messages are used for group notification events, not counted as unread messages. Push service and notification bar alerts are not supported.
The built-in system notifications belong to the types of notifications predefined by CommsEase. The notification messages delivered by the CommsEase server to users are used for system event notifications. Notifications of group changes, such as group join requests, group invitation and more. If your apps also manage friend relationships, notifications for adding and deleting friends also belong to this type. System notifications are received and stored by the SDK, and provide simpler unread management. System notifications are online and offline messages that are not roaming. Push service and notification bar alerts are not supported. You can use custom system notifications.
Notification messages are located in the middle of the chat interface. For example: group name update, XX ledt the group chat.
System notifications are displayed in the verification message list. For example: XX requested to add you as a friend.
Custom messages and custom system notifications
Custom messages are
in-session messages that are delivered for online, offline, and roaming users with alerts on the notification bar. Custom system notifications are sent to online and offline users without roaming.
Custom messages belongs to the messaging system of CommsEase, stored in the message database by the SDK, and displayed to users together with other built-in message types. Custom system notifications are used for some event status. CommsEase does not store or parse these notifications. The SDK transmits and notifies these events only.
Custom messages are the same as text and voice messages, and are located on the left and right sides of the chat interface. For example, guessing games, stickers, and disappearing messages are implemented with custom messages.
A typical scenario for custom system notifications is the "typing indicator" displayed in the P2P chat interface.
Content moderation parameters
The content moderation (anti-spam) parameters in the message structure are as follows:
|Extension field for GuardEase Content Moderator in JSON.
|The data sent for moderation. For more information, see GuardEase extension, format is JSON up to 1024 JSON)
|The moderation result is returned in JSON.
|The field for anti-cheating service
|The data sent for moderation in JSON that contains up to 1,024 characters. For more information, see GuardEase exclusive fields.
- Message types
- Message body
- Notifications and system notifications
- Custom messages and custom system notifications
- Content moderation parameters