Send Group Targeted Message
The SDK supports sending targeted messages in group chats. Targeted messages are only sent to specified users, and other users in the group chat will not receive the message.
Currently, only regular messages are supported; multimedia messages are not supported.
Enable the Service
No service activation is required to use the Send Group Targeted Message feature. However, if you need to store group targeted messages in the server-side historical message records, the following services need to be activated:
- Cloud Storage for One-to-One and Group Messages: You can enable this service for the current App Key on the Chat pricing plans page in the Console. This service is available for Chat Premium Plan or Chat Ultimate Plan. For specific features and pricing, refer to the billing documentation.
- Cloud Storage for Group Targeted Message: You can enable this service in the RC Console by navigating to Configuration > Chat settings > Basic features > One-to-One and Group Chat, and then enabling Cloud Storage for Group Targeted Message.
By default, group targeted messages sent and received by the client are not stored in the historical message service. Therefore, when the client calls the API to retrieve historical messages, the results returned from the RC server will not include the group targeted messages sent or received by the current user.
Send Group Targeted Regular Message
Send a regular message to one or more specified users in a group.
Method
Future<int> sendGroupMessageToDesignatedUsers(RCIMIWMessage message, List<String> userIds, {RCIMIWSendGroupMessageToDesignatedUsersCallback? callback});
Parameter Description
Parameter | Type | Description |
---|---|---|
message | RCIMIWMessage | The message to be sent |
userIds | List<String> | The list of group members |
callback | RCIMIWSendGroupMessageToDesignatedUsersCallback | 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. If the callback parameter is provided, 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 in the interface callback. Non-zero values indicate that the current interface call failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes. |
Code Example
RCIMIWSendGroupMessageToDesignatedUsersCallback? callback = RCIMIWSendGroupMessageToDesignatedUsersCallback(onMessageSaved: (RCIMIWMessage? message) {
//...
}, onMessageSent: (int? code, RCIMIWMessage? message) {
//...
});
int? ret = await engine?.sendGroupMessageToDesignatedUsers(message, userIds, callback:callback);
Callback Methods
-
onGroupMessageToDesignatedUsersAttached
Listener for when the message is saved to the database
Function(RCIMIWMessage? message)? onGroupMessageToDesignatedUsersAttached;
Parameter Description
Parameter | Type | Description |
---|---|---|
message | RCIMIWMessage | The content of the sent message |
Code Example
engine?.onGroupMessageToDesignatedUsersAttached = (RCIMIWMessage? message) {
//...
};
-
onGroupMessageToDesignatedUsersSent
Callback for when the message is sent
Function(int? code, RCIMIWMessage? message)? onGroupMessageToDesignatedUsersSent;
Parameter Description
Parameter | Type | Description |
---|---|---|
code | int | The status code of the interface callback. 0 indicates success, while non-zero values indicate an exception |
message | RCIMIWMessage | The content of the sent message |
Code Example
engine?.onGroupMessageToDesignatedUsersSent = (int? code, RCIMIWMessage? message) {
//...
};