目录

Message Recall

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 November 30, 2022. 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.

Function

You can call this API to recall sent messages. Currently, only notification messages and extended notification messages can be recalled. To avoid misinterpretation, "messages" in this section are referring to notification messages and extended notification messages.

Restrictions

The message body cannot exceed 4096 bytes (excluding push tokens), and the maximum number of push tokens carried at a time cannot exceed 1000 (current system configuration).

Prototype

Protocol

HTTPS POST

Direction

Your server -> Push Kit server

URL

https://push-api.cloud.huawei.com/v1/[clientId]/messages:revoke

NOTE:

[clientId]: Replace it with the client ID of your app. Refer to the guide to obtain the ID.

Data Format

Request: Content-Type: application/json

Response: Content-Type: application/json

Request Parameters

[h2]Request Header

Parameter

Description

Example

Authorization

For details, please refer to Generating a JWT Based on a Service Account.

NOTE:

You are advised to set the JWT validity period to 3600 seconds, within which a JWT can be reused. The value of this parameter is Bearer followed by a space character and then the obtained authentication information.

Bearer eyJraWQiOiIx---xxx.eyJhdWQiOiJodHR---xxx.QRodgXa2xeXSt4Gp---xxx

push-type

Type of the message to be recalled. The options are as follows:

0: notification message

2: extended notification message

0

[h2]Request Body

Parameter

Mandatory

Type

Description

notifyId

Yes

Integer

notifyId contained in message delivery. For details, please refer to notifyId.

token

Yes

Array [String]

Push token of the target user when a message is recalled.

Example: "token": ["************"]

Request Example

// Recall messages based on notifyId and token.
{
    "notifyId": 3114932,
    "token": [
        "pushToken1",
        "pushToken2",
        "pushToken3"
    ]
}

Response Parameters

[h2]Response Body

Parameter

Type

Description

code

String

Response code.

msg

String

Response message.

requestId

String

Request ID.

Response Example

Success response example:

{ 
    "code": "80000000", 
    "msg": "Success", 
    "requestId": "157*******006" 
}

Failure response example:

{ 
    "code": "80100003", 
    "msg": "Illegal payload, The header does not contain valid push-type",
    "requestId": "1690*******1701" 
}

Response Codes

HTTP Response Code

Description

Solution

200

Success.

-

400

Invalid parameter.

Check the service response code and locate the fault accordingly.

401

Authentication failed.

Check the Authorization parameter in the HTTP header.

404

Service not found.

Verify that the request URI is correct.

500

Internal service error.

Submit a ticket online for assistance.

502

The connection request is abnormal, generally because the network is unstable.

Try again later or submit a ticket online.

503

Traffic control.

  • Distribute the sending speed evenly.
  • Spread out push notification delivery to avoid peak sending times.

Service Response Code

Description

Solution

80000000

Success.

-

80100001

Some request parameters are invalid. 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.

80100020

Some content in the message structure is incorrect.

Verify the parameters in the message structure as prompted in the response.

80200001

OAuth authentication error.

Verify the Authorization parameter in the request header.

80200003

OAuth token expired.

The JWT in the Authorization parameter in the HTTP request header has expired. Obtain a new JWT.

80200005

JWT expired.

Generate a new JWT and then send the message.

80300002

The current app does not have the permission to send messages.

1. Sign in to AppGallery Connect and verify that Push Kit has been enabled.

2. Verify that your ClientId is an app-level ClientId.

80300007

All tokens are invalid.

1. In principle, the tokens of different apps on the same device are different. However, the same tokens may exist by mistake in practice.

2. Verify that the package name and app ID configured for the app on the device are the same as those obtained in AppGallery Connect.

3. Devices are upgraded from HarmonyOS 3.x/4.x (HarmonyOS for short) to HarmonyOS NEXT/5.0.x or later (HarmonyOS NEXT for short). As a result, push tokens need to be re-obtained.

80300010

The number of tokens in the message body is 0 or exceeds the default value.

Check the number of tokens. If the number of tokens exceeds the upper limit, send the message to these tokens in batches.

80300017

Tokens in the token list belong to multiple apps.

Verify that tokens in the token list of the message body belong to the same app.

80300028

The app corresponding to the token is different from that corresponding to the ClientId.

1. In principle, the tokens of different apps on the same device are different. However, the same tokens may exist by mistake in practice.

2. Verify that the package name and app ID configured for the app on the device are the same as those obtained in AppGallery Connect.

80300032

No permission to recall messages.

Recall messages based on both token and notifyId.

80000001

System internal error.

Submit a ticket online for assistance.