Push message to all users
Description
It refers to sending messages with specific content, such as text, images, etc., to all online users, including the sender of the message. This feature is suitable for scenarios such as the global announcement of an event or the display of gifts across multiple rooms.
The client receives broadcast messages via the ZIM SDK callback interface and knows which user sent the message.
iOS | Android | macOS | Windows |
---|---|---|---|
broadcastMessageReceived | onBroadcastMessageReceived | broadcastMessageReceived | onBroadcastMessageReceived |
Web | Flutter | React Native | Unity3D |
onBroadcastMessageReceived | broadcastMessageReceived | OnBroadcastMessageReceived | broadcastMessageReceived |
Interface Prototype
- Request method: POST
- Request URL:
https://zim-api.zego.im/?Action=SendMessageToAllUsers
- Transfer protocol: HTTPS
- Call rate limit: 1 time/second, limited to 100 times in 24 hours. Please contact ZEGOCLOUD technical support in case of need.
Request Parameters
The following list includes only the interface request parameters and some common parameters. For a complete list of common parameters, please see Accessing Server APIs.
Parameter | Type | Required or Not | Description |
---|---|---|---|
FromUserId | String | Yes | The sender's user must be registered. |
MessageType | Number | Yes | Message type, please refer to MessageBody Introduction for the applicable types of all user pushes. |
MessageBody | Object | Yes | Message content, please refer to MessageBody Introduction for specific parameter format. Warning Setting is not supported at this time. |
SubMsgType | Number | No(However, it is mandatory when MessageType is set to custom message) | Specific custom types. The values are defined by you and the range of values is [0,200]. |
- FromUserId only supports numbers, English characters, and '!','#','$','%','&','(',')','+','-',':',';','<','=','.','>','?','@','[',']','^','_',' ','{','}','|','~'.
- If the sender's SDK version is lower than 2.0.0, ZIM server only supports Command type message with MessageType 2, and does not support other types.
To provide a better developer experience, ZEGOCLOUD recommends that developers use the latest version of the SDK. - The SDK version of the message receiver must be 2.10.0 or higher. This is necessary to receive broadcast messages from all users.
Request Example
-
Request address URL:
Untitledhttps://zim-api.zego.im/?Action=SendMessageToAllUsers &<Public request parameters>
1 -
Request message body:
Untitled{ "FromUserId": "u1", "MessageType": 1, "MessageBody": { "Message":"hello world", "ExtendedData":"s" }, "SubMsgType": 0 }
1
Response Parameters
Parameter | Type | Description |
---|---|---|
Code | Number | Return code.
Note When you send messages to multiple users at the same time:
|
Message | String | Descriptive information about the result of the request. |
RequestId | String | The Request ID. |
Response Example
{
"Code": 0,
"Message": "success",
"RequestId": "343649807833778782"
}
Return Code
The following only lists the return codes related to the interface business logic. For the complete list of return codes, please refer to Return Codes.
Return Code | Clarification | Processing Suggestions |
---|---|---|
660000002 | Invalid input parameters. | Please check the input parameters. |
660400001 | The size of the message exceeds the limit. | Please check the message size. |
660500002 | The message sender is not logged in to the SDK. | Please log in to the ZIM SDK before sending messages. |
660500003 | The frequency of calling the SendMessageToAllUsers interface exceeds the limit. | Please try again later. |