Overview

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.

Message types

Session messages supported by the IM SDK include the following types:

Type
API keyword
Description Limit
Text message text Messages that use plain text 5,000 characters long.
Image message image Image messages that contain information about image URLs, dimensions, and size. -
Audio message audio 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 message video 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.
File message file 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 message location Location messages that contain the geographic location title, longitude, and latitude. -
Tip message tip 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. -
Notification message notification 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 -
Custom message custom User-defined message type, such as red packets and rock paper scissor -

Message body

The structure of a message body defined in the NIM SDK is NIMMessage. Parameters:

Field Type Description
uuid String Client ID of a message
serverId int The server ID of a message
sessionId String The ID of a chat object (friend account or group ID).
fromAccount String the account of a user that sends a message
sessionType NIMSessionType The session type, such as group chat
senderClientType NIMClientType The type of a client that sends a message
fromNickname String The nickname of a user that sends a message (not supported on Windows and macOS)
messageType NIMMessageType Message type
messageSubType NIMMessageType The subtype of a message
status NIMMessageStatus Message status
messageDirection NIMMessageDirection The message direction that indicates whether a message is sent or received.
isInBlackList bool Whether the sender is in the blocklist of a recipient.
content String The message body. Except the content of a text message or alert message, other types of messages have an empty body.
timestamp int Time when a notification is sent in milliseconds.
messageAttachment NIMMessageAttachment Attachment of a message. The field is valid if the messageType is not text.
attachmentStatus NIMMessageAttachmentStatus Message attachment status (not supported by Windows and macOS)
config NIMCustomMessageConfig message configuration For more information, see NIMCustomMessageConfig.
remoteExtension Map<String, dynamic> 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.
localExtension Map<String, dynamic> 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.
callbackExtension String the custom extension field returned by a webhook.
pushContent String The body of a push notification.
pushPayload Map<String, dynamic> The payload object of a push notification.
memberPushOption NIMMemberPushOption Options of force push notifications for group members
isRemoteRead bool Check whether the message sent by the current user is read.
antiSpamOption NIMAntiSpamOption The content moderation options
yidunAntiCheating Map<String, dynamic> Content Moderator
sessionUpdate bool Whether a message is updated in a session.

Messaging

In addition to rich message types, IM SDK also provides with support for common messages.

Messaging
Description
Offline 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.
Roaming 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
Multi-device sync When the same account logs in on multiple device at the same time, messages are sent to other devices in real time
Message history 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)
Message recall 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.
Read receipt Indicate the read and unread state of messages in group chat and P2P conversations
Message forwarding Forward one or more messages to other users or groups
@mention 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.
Typing indicator The typing indicator can be implemented using a custom system notification. For more information, see: Custom system notification

Concepts

Notifications and system notifications

  • concept

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.

  • Scenarios

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

  • concept

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.

  • Scenarios

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:

Parameter Type Description
yidunAntiSpamExt 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 email, phone number, token, and extension parameters are included in yidunAntiCheating. Additional data are included in yidunAntiSpamExt.
yidunAntiSpamRes Moderation result The moderation result is returned in JSON.
yidunAntiCheating 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. The email, phone number, token, and extension parameters are included in yidunAntiCheating. Additional data are included in yidunAntiSpamExt.
Was this page helpful?
Yes
No
  • Message types
  • Message body
  • Messaging
  • Concepts
  • Notifications and system notifications
  • Custom messages and custom system notifications
  • Content moderation parameters