logo
In-app Chat
Powered Byspreading
On this page

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.

iOSAndroidmacOSWindows
broadcastMessageReceivedonBroadcastMessageReceivedbroadcastMessageReceivedonBroadcastMessageReceived
WebFlutterReact NativeUnity3D
onBroadcastMessageReceivedbroadcastMessageReceivedOnBroadcastMessageReceivedbroadcastMessageReceived

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.

ParameterTypeRequired or NotDescription
FromUserIdStringYesThe sender's user must be registered.
MessageTypeNumberYesMessage type, please refer to MessageBody Introduction for the applicable types of all user pushes.
MessageBodyObjectYesMessage content, please refer to MessageBody Introduction for specific parameter format.
Warning

Setting is not supported at this time.

SubMsgTypeNumberNo(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].
Note
  • 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:

    Untitled
    https://zim-api.zego.im/?Action=SendMessageToAllUsers
    &<Public request parameters>
    
    1
    Copied!
  • Request message body:

    Untitled
    {
        "FromUserId": "u1",
        "MessageType": 1,
        "MessageBody": {
            "Message":"hello world",
            "ExtendedData":"s"
        },
        "SubMsgType": 0
    }
    
    1
    Copied!

Response Parameters

ParameterTypeDescription
CodeNumberReturn code.
Note
When you send messages to multiple users at the same time:
  • If you successfully send messages to one or more users, the Code will return 0, indicating success. In this case, please refer to the specific information in ErrorList to confirm the operation results and see if the message failed to be sent to some users.
  • If the message fails to be sent to all users, the Code will return the corresponding return code. Please refer to Return Codes.
MessageStringDescriptive information about the result of the request.
RequestIdStringThe Request ID.

Response Example

Untitled
{
    "Code": 0,
    "Message": "success",
    "RequestId": "343649807833778782"
}
1
Copied!

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 CodeClarificationProcessing Suggestions
660000002Invalid input parameters.Please check the input parameters.
660400001The size of the message exceeds the limit. Please check the message size.
660500002The message sender is not logged in to the SDK.Please log in to the ZIM SDK before sending messages.
660500003The frequency of calling the SendMessageToAllUsers interface exceeds the limit.Please try again later.

Previous

Recall a room message

Next

Import one-to-one messages