Message Extension
Use Cases
Message extension can be used to add status identifiers to original messages.
- Message Comments: Add comment information by setting the extension information of the original message.
- Gift Redemption & Order Status Updates: Change the display status of messages using this feature. For example, when sending a gift to a user, the default status is "unclaimed," and after the user clicks, the message extension can be set to "claimed."
- Setting Extension Information: This feature allows you to set extension information for a
message
. - Supported Conversation Types: Only one-to-one chat and group chat are supported; chatroom is not supported.
- Built-in Notification Messages: Each time you set a message extension, a built-in notification message will be generated. Frequent setting of extensions may result in a large number of messages.
Setting Message Extensibility
After creating the message, set the expansion
property of the message. By default, it is not enabled. Setting a value will automatically enable it. It can be set when sending the message but cannot be changed after the message is sent.
Code Example
RCIMIWImageMessage? message = await engine.createImageMessage(
type,
targetId,
channelId,
path,
);
message?.expansion = {};
Updating Message Extension Information
- Update the message extension information.
- Call after the message is sent.
Method
Future<int> updateMessageExpansion(String messageUId, Map expansion, {IRCIMIWUpdateMessageExpansionCallback? callback});
Parameter Description
Parameter | Type | Description |
---|---|---|
messageUId | String | The `` of the message, which can be obtained from the message object. Only successfully sent messages will have this value. |
expansion | Map<String, String> | Key-value pairs for the message extension information to be updated, of type HashMap. Key supports combinations of uppercase and lowercase letters, numbers, and special symbols + = - _ . Chinese characters are not supported. Value can include spaces. |
callback | IRCIMIWUpdateMessageExpansionCallback | Event callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is passed, only the callback will be triggered. |
Return Value
Return Value | Description |
---|---|
Future<int> | The status code of the current operation. 0 indicates success. Specific results need to be implemented through 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. |
Code Example
IRCIMIWUpdateMessageExpansionCallback? callback = IRCIMIWUpdateMessageExpansionCallback(onMessageExpansionUpdated: (int? code) {
//...
});
int? ret = await engine?.updateMessageExpansion(messageUId, expansion, callback:callback);
Callback Method
-
onMessageExpansionUpdated
Listener for the interface call result.
Function(int? code, String? messageUId, Map? expansion)? onMessageExpansionUpdated;
Parameter Description
Parameter | Type | Description |
---|---|---|
code | int | The status code of the interface callback. 0 indicates success, non-zero indicates an exception. |
messageUId | String | The `` of the message. |
expansion | Map<String, String> | Key-value pairs for the message extension information to be updated, of type HashMap. |
Code Example
engine?.onMessageExpansionUpdated = (int? code, String? messageUId, Map? expansion) {
//...
};
Deleting Message Extension Information
- Delete specific key-value pairs from the message extension information.
- Call after the message is sent.
Method
Future<int> removeMessageExpansionForKeys(String messageUId, List<String> keys, {IRCIMIWRemoveMessageExpansionForKeysCallback? callback});
Parameter Description
Parameter | Type | Description |
---|---|---|
messageUId | String | The `` of the message, which can be obtained from the message object. Only successfully sent messages will have this value. |
keys | List<String> | The list of keys to be deleted from the message extension information, of type ArrayList. |
callback | IRCIMIWRemoveMessageExpansionForKeysCallback | Event callback. SDK supports callback from version 5.3.1. Other callback methods are deprecated from version 5.4.0. If the callback parameter is passed, only the callback will be triggered. |
Return Value
Return Value | Description |
---|---|
Future<int> | The status code of the current operation. 0 indicates success. Specific results need to be implemented through 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. |
Code Example
IRCIMIWRemoveMessageExpansionForKeysCallback? callback = IRCIMIWRemoveMessageExpansionForKeysCallback(onMessageExpansionForKeysRemoved: (int? code) {
//...
});
int? ret = await engine?.removeMessageExpansionForKeys(messageUId, keys, callback:callback);
Callback Method
- onMessageExpansionForKeysRemoved
Listener for the interface call result.
Function(int? code, String? messageUId, List<String>? keys)? onMessageExpansionForKeysRemoved;
Parameter Description
Parameter | Type | Description |
---|---|---|
code | int | The status code of the interface callback. 0 indicates success, non-zero indicates an exception. |
messageUId | String | The `` of the message. |
keys | List<String> | The list of keys to be deleted from the message extension information, of type ArrayList. |
Code Example
engine?.onMessageExpansionForKeysRemoved = (int? code, String? messageUId, List<String>? keys) {
//...
};
Message Extension Update Listener
Method
Function(Map? expansion, RCIMIWMessage? message)? onRemoteMessageExpansionUpdated;
Parameter Description
Parameter | Type | Description |
---|---|---|
expansion | Map<String, String> | The updated key-value pairs in the message extension information. Only the updated key-value pairs are included, not the entire data. To get all key-value pairs, use the expansion property of the message. |
message | RCIMIWMessage | The message that has changed. |
Code Example
engine?.onRemoteMessageExpansionUpdated = (Map? expansion, RCIMIWMessage? message) {
//...
};
Message Extension Removal Listener
Method
Function(RCIMIWMessage? message, List<String>? keys)? onRemoteMessageExpansionForKeyRemoved;
Parameter Description
Parameter | Type | Description |
---|---|---|
message | RCIMIWMessage | The message that has changed. |
keys | List<String> | The list of keys removed from the message extension information. |
Code Example
engine?.onRemoteMessageExpansionForKeyRemoved = (RCIMIWMessage? message, List<String>? keys) {
//...
};