To ensure network security, Push Kit disabled the TLS 1.0 and TLS 1.1 protocols and unsupported cipher suites for push-related domains on February 28, 2023. After the date, your app is unable to send push messages using the TLS protocol earlier than version 1.2 or unspecified cipher suites.
If your app uses TLS 1.0 or TLS 1.1 to access push-related domains, ensure that the protocol is updated to TLS 1.2 or later.
For details, please refer to Notice on Disabling the TLS 1.0 and TLS 1.1 Protocols for Push Kit Domains. If you have any questions, contact our technical support for help.
The message body cannot exceed 4096 bytes (excluding the token). When messages are sent by token, the maximum number of tokens cannot exceed 1000 (specified by the current system parameter).
Protocol | HTTPS POST |
|---|---|
Direction | Your server -> Push Kit server |
URL | https://push-api.cloud.huawei.com/v1/[clientid]/messages:send NOTE: In the URL, [clientid] indicates the OAuth 2.0 client ID (credential). To obtain the client ID, sign in to AppGallery Connect, click My projects, click the desired project, and go to the Project settings page. |
URL | https://push-api.cloud.huawei.com/v2/[projectid]/messages:send NOTE:
|
Data Format | Request: Content-Type: application/json Response: Content-Type: application/json |
Parameter | Description | Example |
|---|---|---|
Authorization | For details, please refer to Client Credentials. NOTE: This parameter value is Bearer followed by a space character and then the value of access_token. | Bearer CF3Xl2XV6jMKZgqYSZFws9IPlgDvxqOfFSmrlmtkTRupbU2VklvhX9kC9JCnKVSDX2VrDgAPuzvNm3WccUIaDg== |
Parameter | Mandatory (M)/Optional (O) | Type | Description |
|---|---|---|---|
validate_only | O | Boolean | Indicates whether a message is a test message. The test message is only used to verify format validity and is not pushed to user devices. The options are as follows:
|
message | M | Message Object | Message structure, which must contain the valid message payload and valid sending object. For details about the parameters, please refer to the definition in Message Structure. |
Message Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
O | String | Custom message payload. The value can be a JSON string for notification messages, and can be a common string or JSON string for data messages. Example: "your data" or "{'param1':'value1','param2':'value2'}"
| |
notification | O | Notification Object | Notification message content. For details about the parameters, please refer to the definition in Notification Structure. |
android | O | AndroidConfig Object | Android message push control. For details about the parameters, please refer to the definition in AndroidConfig Structure. This parameter is mandatory for Android notification messages. |
apns | O | ApnsConfig Object | iOS message push control. For details about the parameters, please refer to the definition in ApnsConfig Structure. This parameter is mandatory for iOS messages. |
webpush | O | WebPushConfig Object | Web app message push control. For details about the parameters, please refer to the definition in WebPushConfig Structure. This parameter is mandatory for web app notification messages. |
O | Array [String] | Push token of the target user of a message. You must and only can set one of token, topic, and condition. Example: "token":["token1","token2"] NOTE: If the same token is added to the array, the user will receive the same message. Do not enter a duplicate token. | |
O | String | Topic subscribed by the target user of a message. (Currently, this parameter applies only to Android apps.) You must and can only set one of token, topic, and condition. | |
O | String |
|
Notification Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
title | M | String | Notification message title. |
body | M | String | Notification message content. |
image | O | String | URL of the custom small image on the right of a notification message. If this parameter is not set, the image is not displayed. The URL must use the HTTPS protocol, for example, https://example.com/image.png. NOTE: The image size must be less than 512 KB. It is recommended that the dimensions be 40 x 40 dp and corner radius be 8 dp. If the image dimensions exceed the recommended ones, the image may be compressed or displayed incompletely. The recommended image format is JPG, JPEG, or PNG. |
AndroidConfig Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
O | String | Tag of a message in a batch delivery task. The tag is returned to your server when Push Kit sends the message receipt. Your server can analyze message delivery statistics based on bi_tag. | |
O | Integer | Mode for the Push Kit server to cache messages sent to an offline device. These cached messages will be delivered once the device goes online again. The options are as follows:
| |
O | String | Custom message payload. If the data parameter is set, the value of the message.data field is overwritten. | |
fast_app_target | O | Integer | State of a mini program when a quick app sends a data message. The options are as follows:
|
notification | M | AndroidNotification Object | Android notification message structure. For details about the parameters, please refer to the definition in AndroidNotification Structure. |
receipt_id | O | String | Unique receipt ID that associates with the receipt URL and configuration of the downlink message. You can find the receipt ID in Message Receipt. |
O | String | Message cache duration, in seconds. When a user device is offline, the Push Kit server caches messages. If the user device goes online within the message cache time, the cached messages are delivered. Otherwise, the messages are discarded. The default value is 86400s (1 day), and the maximum value is 1296000s (15 days). |
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
M | String | Title of an Android notification message. If the title parameter is set, the value of the message.notification.title field is overwritten. Before a message is sent, you must set at least one of title and message.notification.title. | |
M | String | Body of an Android notification message. If the body parameter is set, the value of the message.notification.body field is overwritten. Before a message is sent, you must set at least one of body and message.notification.body. | |
icon | O | String | Custom app icon on the left of a notification message. The icon file must be stored in the /res/raw directory of your app. For example, the value /raw/ic_launcher indicates the local icon file ic_launcher.xxx stored in /res/raw. Currently, the icon file format can be PNG or JPG. For details about the custom small icon, please refer to Notification Icon Specifications. |
color | O | String | Custom notification bar button color in #RRGGBB format, where RR indicates the red hexadecimal color, GG indicates the green hexadecimal color, and BB indicates the blue hexadecimal color. Example: #FFEEFF |
sound | O | String | Custom ringtone. This parameter is valid when a channel is created. The ringtone file specified by this parameter must be stored in the /res/raw directory of your app. For example, the value /raw/shake indicates the local icon file shake.xxx stored in /res/raw. The ringtone file format can be MP3, WAV, or MPEG. If you do not set this parameter, the default ringtone will be used. NOTE: The ringtone is an attribute of the notification channel. Therefore, a ringtone is valid only if it is set during channel creation. If a ringtone is set after the channel is created, it will not be played and the one set during channel creation is played instead. |
O | Boolean | Indicates whether to use the default ringtone. The options are as follows:
| |
tag | O | String | Message tag. Messages that use the same message tag in the same app will be overwritten by the latest message. |
M | ClickAction Object | Message tapping action. For details about the parameters, please refer to the definition of ClickAction Structure. This parameter is mandatory for Android notification messages. | |
O | String | ID in a string format of the localized message body. For details, please refer to Notification Message Localization. | |
O | Array [String] | Variables of the localized message body. For details, please refer to Notification Message Localization. Example: "body_loc_args":["1","2","3"] | |
O | String | ID in a string format of the localized message title. For details, please refer to Notification Message Localization. | |
O | Array [String] | Variables of the localized message title. For details, please refer to Notification Message Localization. Example: "title_loc_args":["1","2","3"] | |
O | Object | Multi-language parameter. body_loc_key and title_loc_key are read from multi_lang_key first. If they are not read from multi_lang_key, they will be read from the local character string of the APK. For details, please refer to Notification Message Localization. A maximum of three languages can be set. | |
O | String | Custom channel for displaying notification messages. Custom channels are supported in the Android O version or later. For details, please refer to Notification Channel Customization. | |
notify_summary | O | String | Brief description of a notification message to an Android app. |
O | String | URL of the custom small image on the right of a notification message. The function is the same as that of the message.notification.image field. If the image parameter is set, the value of the message.notification.image field is overwritten. The URL must be an HTTPS URL. Example: https://example.com/image.png NOTE: The image size must be less than 512 KB. It is recommended that the dimensions be 40 x 40 dp and corner radius be 8 dp. If the image dimensions exceed the recommended ones, the image may be compressed or displayed incompletely. The recommended image format is JPG, JPEG, or PNG. | |
style | O | Integer | Notification bar style. The options are as follows:
|
O | String | Android notification message title in large text style. This parameter is mandatory when style is set to 1. When the notification bar is displayed after big_title is set, big_title instead of title is used. | |
O | String | Android notification message body in large text style. This parameter is mandatory when style is set to 1. When the notification bar is displayed after big_body is set, big_body instead of body is used. | |
notify_id | O | Integer | Unique notification ID of a message. If a message does not contain the ID or the ID is -1, Push Kit will generate a unique ID for the message. Different notification messages can use the same notification ID, so that new messages can overwrite old messages. |
group | O | String | Message group. For example, if 10 messages that contain the same value of group are sent to a device, the device displays only the latest message and the total number of messages received in the group, but does not display these 10 messages. |
O | BadgeNotification Object | Android notification message badge control. For details about the parameters, please refer to the definition in BadgeNotification Structure. | |
ticker | O | String | Content displayed on the status bar after the device receives a notification message. Due to the restrictions of the Android native mechanism, the content will not be displayed on the status bar on the device running Android 5.0 (API Level 21) or later even if this field is set. |
when | O | String | Time when Android notification messages are delivered, in the UTC timestamp format. If you send multiple messages at the same time, they will be sorted based on this value and displayed in the Android notification panel. Example: 2014-10-02T15:01:23.045123456Z |
importance | O | String | Android notification message priority, which determines the message notification behavior of a user device. The options are as follows: |
use_default_vibrate | O | Boolean | Indicates whether to use the default vibration mode. The default value is true. |
O | Boolean | Indicates whether to use the default breathing light. The default value is true. | |
O | Array [String] | Custom vibration mode for an Android notification message. Each array element adopts the format of [0-9]+|[0-9]+[sS]|[0-9]+[.][0-9]{1,9}|[0-9]+[.][0-9]{1,9}[sS], for example, ["3.5S","2S","1S","1.5S"]. A maximum of ten array elements are supported. The value of each element is an integer ranging from 1 to 60. EMUI 11 is not supported. Example: "vibrate_config":["1","3"] | |
O | String | Android notification message visibility. The options are as follows:
| |
light_settings | O | LightSettings Object | Custom breathing light color. For details about the parameters, please refer to the definition in LightSettings Structure. |
O | Boolean | Indicates whether to display notification messages when an app is running in the foreground. The default value is true. For details, please refer to Notification Message Processing for Apps Running in the Foreground. | |
profile_id | O | String | ID of the user-app relationship. The value contains a maximum of 64 characters. |
O | Array [String] | Content in inbox style. A maximum number of five content records are supported and each record can contain at most 1024 characters. This parameter is mandatory when style is set to 3. For details about the display effect, please refer to Inbox Style for a Notification Message. Example: "inbox_content":["content1","content2","content3"] | |
buttons | O | Array [Button Object] | Action buttons of a notification message. A maximum of three buttons can be set. For details about the parameters, please refer to the definition in Button Structure. Example: "buttons":[{"name":"Open app","action_type":"1"}] |
Button Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
name | M | String | Button name, which cannot exceed 40 characters. |
action_type | M | Integer | Button action. The options are as follows:
|
intent_type | O | Integer | Method of opening a custom app page. The options are as follows:
This parameter is mandatory when action_type is set to 1. |
O | String |
| |
data | O | String |
|
ClickAction Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
M | Integer | Message tapping action type. The options are as follows:
| |
intent | O | String | For details about intent implementation, please refer to Setting the intent Parameter. When type is set to 1, you must set at least one of intent and action. |
url | O | String |
|
O | String | Action corresponding to the activity of the page to be opened when the custom app page is opened through the action. When type is set to 1 (open a custom page), you must set at least one of intent and action. |
BadgeNotification Structure
LightSettings Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
color | M | Color Object | Breathing light color. This parameter is mandatory when light_settings is set. For details about the parameters, please refer to the definition in Color Structure. |
light_on_duration | M | String | Interval when a breathing light is on, in the format of \d+|\d+[sS]|\d+.\d{1,9}|\d+.\d{1,9}[sS]. This parameter is mandatory when light_settings is set. |
light_off_duration | M | String | Interval when a breathing light is off, in the format of \d+|\d+[sS]|\d+.\d{1,9}|\d+.\d{1,9}[sS]. This parameter is mandatory when light_settings is set. |
Color Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
alpha | O | Float | Alpha setting of the RGB color. The default value is 1, and the value range is [0, 1]. |
red | O | Float | Red setting of the RGB color. The default value is 0, and the value range is [0, 1]. |
green | O | Float | Green setting of the RGB color. The default value is 0, and the value range is [0, 1]. |
O | Float | Blue setting of the RGB color. The default value is 0, and the value range is [0, 1]. |
ApnsConfig Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
headers | O | Object | APNs message headers. For details about the parameters, visit the Apple Developer website. |
payload | M | Object | APNs message payload. If title and body are set in the message payload, the values of the message.notification.title and message.notification.body fields are overwritten. Before a message is sent, you must set at least one of title and body and at least one of message.notification.title and message.notification.body. For details about the parameters, visit the Apple Developer website. |
hms_options | M | ApnsConfig.HmsOptions Object | HMS parameter for APNs. For details about the parameter, please refer to the definition in ApnsConfig.HmsOptions Structure. |
ApnsConfig.HmsOptions Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
target_user_type | M | Integer | Target user type. The options are as follows:
|
WebPushConfig Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
headers | O | Headers Object | Headers of a message sent through the WebPush agent. For details about the parameters, please refer to the definition in Headers Structure. |
notification | O | WebNotification Object | Structure of a notification message sent through the WebPush agent. For details about the parameters, please refer to the definition in WebNotification Structure. |
hms_options | O | WebPushConfig.HmsOptions Object | WebPush agent parameter. For details about the parameter, please refer to the definition in WebPushConfig.HmsOptions Structure. |
Headers Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
ttl | O | String | Message cache time, in seconds, for example, 20, 20s, or 20S. The default value is 86400S. |
topic | O | String | Message ID, which can be used to overwrite undelivered messages. |
WebNotification Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
title | O | String | Title of a web app notification message. If the title parameter is set, the value of the message.notification.title field is overwritten. Before a message is sent, you must set at least one of title and message.notification.title. |
body | O | String | Body of a web app notification message. If the body parameter is set, the value of the message.notification.body field is overwritten. Before a message is sent, you must set at least one of body and message.notification.body. |
icon | O | String | Small icon URL. |
image | O | String | Large image URL. |
lang | O | String | Language |
tag | O | String | Notification message group tag. Multiple same tags are collapsed and the latest one is displayed. This function is used only for mobile phone browsers. |
badge | O | String | Browser icon URL, which only applies to mobile phone browsers and is used to replace the default browser icon. |
dir | O | String | Text direction. The options are as follows:
|
vibrate | O | Array [Integer] | Vibration interval, in milliseconds. Example: [100,200,300] |
renotify | O | Boolean | Message reminding flag. |
require_interaction | O | Boolean | Indicates that notification messages should remain active until a user taps or closes them. |
silent | O | Boolean | Message sound-free and vibration-free reminding flag. |
timestamp | O | Long | Standard Unix timestamp. |
actions | O | Array [WebActions Object] | Message action. For details about the parameters, please refer to the definition in WebActions Structure. |
WebActions Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
action | O | String | Action name. |
icon | O | String | URL for the button icon of an action. |
title | O | String | Title of an action. |
WebPushConfig.HmsOptions Structure
Mandatory (M)/Optional (O) | Type | Description | |
|---|---|---|---|
link | O | String | Default URI for redirection when no action is performed. |
For details, please refer to Sample Code for Sending Downlink Messages Through HTTPS.
Response Body
Parameter | Type | Description |
|---|---|---|
code | String | Result code. |
msg | String | Result code description. |
requestId | String | Request ID. |
HTTP Status Code | Description | Solution |
|---|---|---|
200 | Success. | - |
400 | Incorrect parameter. | Rectify the fault based on the status code description. |
401 | Authentication failed. | Verify the access token in the Authorization parameter in the request HTTP header. |
404 | Service not found. | Verify that the request URI is correct. |
500 | Internal service error. | Contact technical support. |
502 | The connection request is abnormal, generally because the network is unstable. | Try again later or contact technical support. |
503 | Traffic control. |
|
Service Result Code | Description | Solution |
|---|---|---|
80000000 | Success. | N/A |
80100000 | The message is successfully sent to some tokens. Tokens identified by illegal_tokens are those to which the message failed to be sent. Response example: {
"code": "80100000",
"msg": "{\"success\":3,\"failure\":1,\"illegal_tokens\":[\"xxx\"]}",
"requestId": ""
} | Verify these tokens in the return value. |
80100001 | Some request parameters are incorrect. Response example: {
"code": "80100001",
"msg": "UnSupported svc",
"requestId": ""
} | Verify the request parameters as prompted in the response. |
80100003 | Incorrect message structure. | Verify the parameters in the message structure as prompted in the response. |
80100004 | The message expiration time is earlier than the current time. | Verify the message field ttl. |
80100013 | The collapse_key message field is invalid. | Verify the message field collapse_key. |
80100017 | A maximum of 100 topic-based messages can be sent at the same time. | Increase the interval for sending topic-based messages. |
80200001 | OAuth authentication error. | The access token in the Authorization parameter in the request HTTP header failed to be authenticated. Ensure that the access token is correct.
|
80200003 | OAuth token expired. | The access token in the Authorization parameter in the request HTTP header has expired. Obtain a new access token. |
80300002 | The current app does not have the permission to send messages. |
|
80300007 | All tokens are invalid. |
|
80300008 | The message body size (excluding the token) exceeds the default value (4096 bytes). | Reduce the message body size. |
80300010 | The number of tokens in the message body exceeds the default value. | Reduce the number of tokens and send messages to the tokens in batches. |
80300013 | Invalid receipt URL. | Verify that your receipt URL is correct and the receipt certificate does not expire. |
80600003 | Failed to request the OAuth service. | Check the OAuth 2.0 client ID and client secret. |
81000001 | An internal error of the system occurs. | Contact technical support. |