Send Group Targeted Message
The SDK supports sending targeted messages in group chat sessions. Targeted messages are only sent to specified users, and other users in the group chat session will not receive this message.
Currently, only sending regular messages is supported; sending multimedia messages is not supported.
Enable Service
Using the Send Group Targeted Message feature does not require enabling a service. Note that if you need to store group targeted messages in the server's historical message records, you need to enable the following services:
- Cloud Storage for One-to-One and Group Messages service. You can go to the Chat pricing plans page in the Console to enable this service for the App Key you are using. Chat Premium Plan or Chat Ultimate Plan can enable this service. Specific features and fees are subject to the Billing Instructions document.
- Cloud Storage for Group Targeted Message service, which requires submitting a ticket to apply for activation.
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
sendGroupMessageToDesignatedUsers(
message: RCIMIWMessage,
userIds: Array<string>,
callback: RCIMIWSendGroupMessageToDesignatedUsersCallback
): Promise<number>;
Parameter Description
Parameter | Type | Description |
---|---|---|
message | RCIMIWMessage | The message to be sent |
userIds | Array<string> | Collection of group members |
callback | RCIMIWSendGroupMessageToDesignatedUsersCallback | Callback for the interface call result. |
Return Value
Return Value | Description |
---|---|
number | The status code of the current interface operation. 0 indicates a successful call. The specific result needs to be implemented in the interface callback. Non-zero indicates that the current interface call operation failed, and the interface callback will not be triggered. For detailed errors, refer to the error codes. |
Code Example
const callback = {
onMessageSaved: (message: RCIMIWMessage) => {
//...
},
onMessageSent: (code: number, message: RCIMIWMessage) => {
//...
},
};
let code = await engine.sendGroupMessageToDesignatedUsers(message, userIds, callback);