We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All

Downlink Message Sending

Push Kit allows you to use HTTPS to access its server and send uplink messages and downlink messages. This section describes the downlink messaging.

The following figure shows the downlink messaging.

  1. Obtain an access token. For details, please refer to Client Credentials.
  2. Call the downlink messaging API to send a message. For details about the message body, please refer to Sending Downlink Messages. For details about result codes, please refer to Result Codes.

    URL for calling the API using HTTPS POST:

    POST https://push-api.cloud.huawei.com/v1/[clientid]/messages:send
    NOTE

    Replace the value of [clientid] with the client ID of your app, which can be obtained from the Project settings page.

    Request header example:

    Content-Type: application/json; charset=UTF-8
    Authorization: Bearer CF3Xl2XV6****************************************Nm3WccUIaDg== 
    NOTE
    • The value of the Authorization parameter in the request header is an access token.
    • If the access token is manually obtained, for example, by running the curl command or using Postman, remember to restore the escape character \/ to / in the JSON character string so that the obtained access token is correct. To obtain a correct access token during code execution, you can use any third-party library to parse the JSON string.
    Notification message body example:
    {
        "validate_only": false,
        "message": {
            "android": {
                "notification": {
                    "title": "test title",
                    "body": "test body",
                    "click_action": {
                        "type": 3
                    }
                }
            },
            "token": ["pushtoken1"]
        }
    }
    Data message body example:
    {
        "validate_only": false,
        "message": {
            "data": "{'param1':'value1','param2':'value2'}",
            "token": ["pushtoken1"]
        }
    }
    NOTE

    For details request parameters, please refer to Sending Downlink Messages.

  3. Your app server receives a message receipt. For details, please refer to Message Receipt.
NOTE

Huawei provides Java Sample Code for you to encapsulate server APIs.

Search
Enter a keyword.