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
  • MessageBody Introduction

MessageBody Introduction

Last updated:2023-10-12 19:02

ZIM server supports developers to send different types of messages to the session through the server API, and the supported types are shown in the table below:

Message Type MessageType Value Applicable Session Type Supports Broadcast to All Members
1
  • Single Chat.
  • Group Chat.
  • Room.
✔️
2
11
✔️
12
✔️
13
✔️
14
✔️
200
✔️
20
Room。

When developers call the ZIM server interface to send messages, they need to pass the message content through the parameter MessageBody. The format of MessageBody varies depending on the message type. This article will introduce the corresponding parameters for each message type.

Text messages, custom messages and pop-up messages

MessageBody structure 

The MessageBody structure is the same for text messages, custom messages and pop-up messages, as described below:

Parameters Type Required or not Description
Message
String
Yes
The message content, by default, is 2 KB. If necessary, please contact ZEGO technical support for configuration, with a maximum capacity of up to 32 KB.
ExtendedData
String
No
Extended field with a maximum length of 1 KB.
OfflinePush
Object
No
Offline Push.
Enable
Number
No
Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
Title
String
Yes (only if OfflinePush is filled in)
The title of the offline push display, 20 bytes max.
Content
String
Yes (only if OfflinePush is filled in)
Offline Push Displayed Content, 50 bytes max.
Payload
String
No
Extended fields allow developers to customise the behaviour after receiving an offline push message.

MessageBody example

{
    "MessageBody": {
        "Message":"hello world",
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        }
    }
}

signaling message

MessageBody framework

Parameters Type Required or not Description
Message
String
Yes
The content of signaling messages is by default limited to 2 KB. If necessary, please contact ZEGO technical support for configuration, and the maximum limit can be extended to 32 KB.

If the message is base64 encoded, the length limit here refers to the original message length before base64 encoding.

ExtendedData
String
No
Extended field, up to 1 KB in length.
IsBase64
Number
No
Whether the message is base64 encoded.
  • 0: No (default).
  • 1:Yes. After receiving this message, the ZIM server will perform base64 decoding to obtain the actual message content, and then send it to the ZIM SDK.

MessageBody example

{
    "MessageBody": {
        "Message":"hello world",
        "ExtendedData":"extendedData",
        "IsBase64":0
    }
}

Picture message

MessageBody framework

Parameters Type Required or not Description
Message
String
Yes
Picture message content, a JSON byte string generated according to Message framework , defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.
ExtendedData
String
No
Extended field, up to 1 KB in length.
OfflinePush
Object
No
Offline Push.
Enable
Number
No
Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
Title
String
Yes(only if OfflinePush is filled in)
The title of the offline push display, 20 bytes max.
Content
String
Yes(only if OfflinePush is filled in)
The content Offline Push displayed, 50 bytes max.
Payload
String
No
Extended fields allow developers to customise the behaviour after receiving the offline push message.

Message framework

Parameters Type Required or not Description
Uid
String
Yes
The unique ID of the image, whihc is generated by the developer.
Origin
Object
Yes
Original image.
Url
String
Yes
The URL address of the image, with a maximum length of 500 bytes.
Width
Number
Yes
Picture width in pixels(px).
Height
Number
Yes
Picture heightin pixels(px).
FileName
String
Yes
File name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
Size
Number
No
Image data size in bytes.

Message example

{
    "Uid":"343649807833778782", 
    "Origin": {
        "Url":"https:xxx", 
        "Width":100,
        "Height":200
    },
    "FileName":"FileName.jpg", 
    "Size":1024
}

MessageBody example

{
    "MessageBody": {
        "Message":"", // The content of the image message is a JSON byte string generated according to the Message structure of the image message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
                "Enable":0, 
                "Title":"Title",
                "Content":"Content", 
                "Payload":"data"
        }
    }
}

Text message

MessageBody framework

Parameters Type Required or not Description
Message
String
Yes
The content of the file message, a JSON byte string generated according to the Message structure of the file message, defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.
ExtendedData
String
No
Extended field with a maximum length of 1 KB.
OfflinePush
Object
No
Offline Push.
Enable
Number
No
Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
Title
String
Yes(only if OfflinePush is filled in)
The title of the offline push display, 20 bytes max.
Content
String
Yes(only if OfflinePush is filled in)
The content Offline Push displayed, 50 bytes max.
Payload
String
No
Extended fields allow developers to customise the behaviour after receiving an offline push message.

Message framework

Parameters Type Required or not Description
Uid
String
Yes
The unique ID of the file. generated by the developer.
Url
String
Yes
The URL address of the file, and the maximum length is 500 bytes.
FileName
String
Yes
File name in the recommended format "xxx.file extension" with a maximum length of 150 bytes
Size
Number
No
Image data size in bytes.

Message example

{
      "Uid":"343649807833778782", 
      "Url":"https:xxx", 
      "FileName":"FileName.txt", 
      "Size":1024
}

MessageBody example

{
    "MessageBody": {
        "Message":"", // The content of the file message, which is a JSON byte string generated according to the Message structure of the file message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
       }
    }
}

Audio message

MessageBody framework

Parameters Type Required or not Description
Message
String
Yes
The content of the video message, a JSON byte string generated according to the Message structure of the audio message, defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.
ExtendedData
String
No
Extended field with a maximum length of 1 KB.
OfflinePush
Object
No
Offline Push.
Enable
Number
No
Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
Title
String
Yes(only if OfflinePush is filled in)
The title of the offline push display, 20 bytes max.
Content
String
Yes(only if OfflinePush is filled in)
The content Offline Push displayed, 50 bytes max.
Payload
String
No
Extended fields allow developers to customise the behaviour after receiving an offline push message.

Message framework

Parameters Type Required or not Description
Uid
String
Yes
A unique ID for the audio. generated by the developer.
Url
String
Yes
URL address of the audi, and the maximum length is 500 bytes.
FileName
String
Yes
Audio name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
Size
Number
No
Audio data size in bytes.
MediaDuration
Number
No
Audio duration in seconds.

Message example

{
    "Uid":"343649807833778782", 
    "Url":"https:xxx", 
    "FileName":"FileName.mp3", 
    "Size":1024,
    "MediaDuration":30
}

MessageBody example

{
    "MessageBody": {
        "Message":"", // The content of the audio message, a JSON byte string generated according to the Message structure of the audio message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        }
    }
}

Video Message

MessageBody framework

Parameters Type Required or not Description
Message
String
Yes
Video message content, a JSON byte string generated according to Message framework defaults to 2 KB. Please contact ZEGO technical support for configurations up to 32 KB if needed.
ExtendedData
String
No
Extended field with a maximum length of 1 KB.
OfflinePush
Object
No
Offline Push.
Enable
Number
No
Whether to enable offline push:

  • 0:Not to push (default).
  • 1:Push.
Title
String
Yes(only if OfflinePush is filled in)
The title of the offline push display, 20 bytes max.
Content
String
Yes(only if OfflinePush is filled in)
The content Offline Push displayed, 50 bytes max.
Payload
String
No
Extended fields for developers to customise their behaviour after receiving an offline push message.

Message framework

Parameters Type Required or not Description
Uid
String
Yes
The unique ID of the file. generated by the developer.
Url
String
Yes
The URL address of the video, the maximum length is 500 bytes.
FileName
String
Yes
Video name in the recommended format "xxx.file extension" with a maximum length of 150 bytes.
Size
Number
No
Audio data size, measured in bytes.
MediaDuration
Number
No
Video duration in seconds.
Thumbnail
Object
No
Video first frame.
Url
String
Yes(Only if the first frame of the video is required)
The URL address of the thumbnail, the maximum length is 500 bytes.
Width
Number
Yes(Only if the first frame of the video is required)
Picture width in pixels(px).
Height
Number
Yes(Only if the first frame of the video is required)
Picture height in pixels(px).

Message example

{
    "Uid":"343649807833778782", 
    "Url":"https:xxx", 
    "FileName":"FileName.mp4", 
    "Size":1024,
    "MediaDuration":300,
    "Thumbnail": {
        "Url":"https:xxx", 
        "Width":100,
        "Height":200
    }
}

MessageBody example

{
    "MessageBody": {
        "Message":"", // The content of the video message as a JSON byte string generated from the Message structure of the audio message.
        "ExtendedData":"extendedData",
        "OfflinePush" :{
            "Enable":0, 
            "Title":"Title",
            "Content":"Content", 
            "Payload":"data"
        }
    }
}
Page Directory