- Documentation
- In-app Chat
- Server APIs
- Send group messages
Send group messages
Description
Send group messages and push to all online users in the group.
Request limit: 10 requests/second.
The client will receive notifications of group messages through the event callback of the ZIM SDK.
Platform | Callback |
---|---|
iOS/macOS |
zim:receiveGroupMessage:fromUserID: |
Android |
onReceiveGroupMessage |
Windows |
onReceiveGroupMessage |
Request method and endpoint
- Request method: POST
- Request address: https://zim-api.zego.im/?Action=SendGroupMessage
- Transmission protocol: HTTPS
Request parameters
Listed below are the parameters specific to this request and part of the public request parameters. For the complete list of public request parameters, see Accessing Server APIs - Public parameters.
Parameter | Type | Required | Description |
---|---|---|---|
FromUserId |
String |
Yes |
The ID of the user who send the message. |
GroupId |
String |
Yes |
Group ID. |
MessageType |
Number |
Yes |
Message type, the values are as follows:
|
Priority |
Number |
Yes |
Message priority, the values are as follows:
|
MessageBody |
Object |
Yes |
Message content. |
The FromUserId
and GroupId
can only contain numbers, letters, and the following special characters: !#$%&()+-:;<=.>?@[]^_{}|~.
The format of MessageBody
varies according to the value of MessageType
. The following table shows the details:
MessageType | MessageBody format | Type | Required | Description |
---|---|---|---|---|
1 (Text message) |
Message |
String |
Yes |
Text message content, it is 2 KB by default. Size limit: 32 KB. For a larger configuration, contact ZEGOCLOUD Technical Support. |
ExtendedData |
String |
No |
Extension field. |
|
OfflinePush |
Object |
No |
Offline notification. |
|
└ Enable |
String |
No |
Enable or disable the offline notifications:
|
|
└ Title |
String |
Yes (required only when the OfflinePush is filled) |
The title of the offline notification. Maximum number of characters: 20 |
|
└ Content |
String |
Yes (required only when the OfflinePush is filled) |
The offline notification content. Maximum number of characters: 50 |
|
└ Payload |
String |
No |
The action after receiving the offline notification. |
|
2 (Command/Signaling message) |
Message |
String |
Yes |
Message content, it is 2 KB by default. Size limit: 32 KB. For a larger configuration, contact ZEGOCLOUD Technical Support. |
ExtendedData |
String |
No |
Extension field. |
The ZIM Server only supports the Command message type (the MessageType
is 2
) if the version of the SDK you are using is earlier than 2.0.0.
For a better development experience, we recommend you use the latest version of SDK.
Sample request
A sample URL request:
https://zim-api.zego.im/?Action=SendGroupMessage &<Public parameters>
Request message body:
{ "FromUserId": "u1", "GroupId": "r1", "MessageType": 1, "Priority": 1, "MessageBody": { "Message":"hello world", "ExtendedData":"d", "OfflinePush" :{ "Enable":0, "Title":"Title", "Content":"Content", "Payload":"data" } } }
Response parameters
Parameter | Type | Description |
---|---|---|
Code |
Number |
Return code. |
Message |
String |
Description of the request execution result. |
RequestId |
String |
Request ID. |
Sample response
{
"Code":0,
"Message":"success",
"RequestId":"343649807833778782"
}
Return codes
Listed below are the return codes related to this API. For the complete list of return codes, see Return codes.
Return code | Possible cause and solutions |
---|---|
660600001 |
The group does not exist. Please check the group ID. |
660400001 |
The size of message has exceeded the limit. Please check the message size. |
660500002 |
The message sender has not logged in. Please log in first before sending messages. |