In-app Chat
  • iOS : Objective-C
  • Android
  • Web
  • Flutter
  • React Native
  • Unity3D
  • Windows
  • macOS
  • Introduction
    • Overview
    • Basic concepts
  • Sample app
  • Getting started
  • Client SDKs
    • SDK downloads
    • Release notes
    • Upgrade guide
  • Guides
    • Authentication
    • Manage users
    • Room
    • Group
    • Messaging
    • Call invitation (signaling)
    • Manage sessions
  • Offline push notifications
  • Error codes
  • Client APIs
  • Server APIs
  • Documentation
  • In-app Chat
  • Server APIs
  • Push message to all users

Push Message To All Users

Last updated:2024-04-01 10:59

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.

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.

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(for version description, please refer to Release notes 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:

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

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

Response Parameters

Parameter Type Description
Code
Number
Return code.

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.
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.
Page Directory