目录

Message Receipt

Function Description

This API is used by the Push Kit server to send receipts to your server.

Restrictions

You need to enable the message receipt permission in AppGallery Connect. For details, please refer to Enabling the Receipt Permission.

The receipt API versions include V1 and V2. The request header and response parameters are the same for receipt messages of different API versions. The only difference lies in the request body. Scenario-specific message push supports only the V2 version.

API Prototype

Protocol Direction URL Data Format
HTTPS POST Push Kit server -> Your server for receiving receipts Address of your server for receiving receipts, which is the same as that defined in AppGallery Connect.

Request: Content-Type: application/json

Response: Content-Type: application/json

Request Parameters

[h2]Request Header

Parameter Description Example
X-HUAWEI-CALLBACK-ID Message header authentication parameter, which is optional. This parameter is mandatory when both the callback user name and key have been set in the receipt configuration.

timestamp=1563*****1261; nonce=a07bfa17-6d82-4b53-a9a2-07c*****eef1; value=E4Ye*****HZ6592U8B9S37238E+Hwtjfrmpf8AQXF+c=

· timestamp: milliseconds-level timestamp.

· nonce: random UUID.

· value: Base64-encoded string that has been HMAC-SHA256 encrypted using the callback key. The string before encryption consists of timestamp, nonce, and callback user name, without plus signs (+). For details, please refer to the sample code.

[h2]Request Body

Parameter Mandatory Type Description
statuses Yes Array [statuses Object] Receipt message content, which is an array of up to 100 statuses structures. It has both V1 and V2 versions. Only the V2 version is supported here.

statuses (V2)

Parameter Mandatory Type Description
token Yes String Token of the user to which a message is sent. The token is sent to your app server.
pushType Yes Integer Message type. For details, please refer to push-type.
appPackageName Yes String App package name of the message sender.
biTag No String The value is the same as that of biTag contained in the message you send. If biTag is not set for the delivered message, this parameter is empty.
requestId Yes String Request ID, which is returned by the message sending API.
deliveryStatus No deliveryStatus Object Message delivery status (deliveryStatus). This parameter is applicable to receipts for messages other than widget update messages.
formStatus No formStatus Object Delivery status of a widget update message (formStatus). This parameter is applicable only to receipts for widget update messages.

deliveryStatus

Parameter Mandatory Type Description
result Yes Integer Receipt status code for message delivery. For details, please refer to Receipt Status Codes.
timestamp Yes Long Millisecond-level timestamp when the message successfully arrives at the client. If the message fails to arrive at the client, the value of this parameter is the timestamp when the receipt message is generated.

formStatus

Parameter Mandatory Type Description
formId Yes Long Instance ID of a service widget, which is obtained when onAddForm is called (when a user adds the widget to the home screen). The maximum value is 231-1.
result Yes Integer Receipt status code for message delivery. For details, please refer to Receipt Status Codes.
timestamp Yes Long Millisecond-level timestamp when the message successfully arrives at the client. If the message fails to arrive at the client, the value of this parameter is the timestamp when the receipt message is generated.

Request Example

{
  "statuses": [
    {
      "biTag": "131415",
      "pushType": 0,
      "appPackageName": "com.****",
      "token": "148896*******000001",
      "requestId": "1*******0",
      "deliveryStatus":{
        "result": 0,
        "timestamp": 1607832761768
      }
    }
  ]
}

Response Parameters

Parameter Mandatory Type Description
code Yes String Processing result code returned by your server.
message Yes String Description of the processing result code returned by your server.

Response Example

{
  "code": "0",
  "message": "success"
}