目录

Message Revocation

Function Description

You can call this API to revoke sent messages. Currently, only notification messages and text-to-speech messages can be revoked. To avoid misinterpretation, "messages" in this section are referring to notification messages and text-to-speech messages.

Constraints

The message body cannot exceed 4096 bytes (excluding the push token). Otherwise, error code 80300008 will be returned. The number of push tokens carried in a single request cannot exceed 1000 (the current system configuration value).

API Prototype

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

Request Parameters

[h2]Request Header

Parameter Description Example
Authorization

Authentication method:

JWT:

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.

This parameter value 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 revoked. The options are as follows:

0: notification message

2: text-to-speech message

0

[h2]Request Body

Parameter Mandatory Type Description
notifyId Yes Integer notifyId carried when the message is sent. For details, please refer to notifyId.
token Yes Array [String]

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

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

NOTE

A maximum of 1000 tokens can be carried each time.

Request Example

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

Response Parameters

[h2]Response Body

Parameter Mandatory Type Description
code Yes String Response code.
msg Yes String Response code description.
requestId Yes String Request ID.

Response Examples

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"
}

HTTP Response Codes

HTTP Response Code Description Solution
200 Success. -
400 Parameter error. Check the service response code and locate the fault based on it.
401 Authentication failure. Check the Authorization parameter in the HTTP header.
404 Service not found. Check the request URL.
500 Internal service error. Submit a ticket online.
502 Connection error. This typically occurs when network connectivity is unstable. Try again later. If the fault persists, submit a ticket online.
503 Traffic control.

· Distribute the sending speed evenly.

· Spread out push notification delivery to avoid peak sending times.

Service Response Codes

[h2]80000000 Success

Message

Success.

Symptom

Sent successfully.

Possible causes

Sent successfully.

Solution

None

[h2]80100001 Some Request Parameters Are Invalid

Message

Check Parameter Error.

Symptom

Some request parameters are invalid.

Possible causes

Some request parameters are invalid.

Solution

Check and modify request parameters as prompted by the response.

[h2]80100003 Incorrect Message Structure

Message

Illegal payload, {errorTips}.

Symptom

Incorrect message structure.

Possible causes

Incorrect message structure.

Solution

Check and modify the request body structure as prompted by the response.

[h2]80100020 Some Content in Message Structure Is Incorrect

Message

Check Parameter Partial Success.

Symptom

Some content in the message structure is incorrect.

Possible causes

Some content in the message structure is incorrect.

Solution

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

[h2]80200001 Authentication Error

Message

Authentication Error.

Symptom

Authentication error.

Possible causes

  1. The request does not contain the Authorization parameter, or the Authorization parameter is left empty.

  2. The project ID used for requesting the JWT and the client ID contained in the push request do not belong to the same project.

  3. The JWT in the Authorization parameter does not match the app.

Solution

Rectify the authentication failure of the Authorization parameter in the request header as prompted by the response.

  1. Verify that the request contains the Authorization parameter, and the Authorization parameter is not empty.

  2. Verify that the value of clientId in the push request URL (https://push-api.cloud.huawei.com/v1/[clientId]/messages:revoke) matches the project to which your app belongs. For details, please refer to step 2 in Generating a JWT Based on a Service Account.

  3. Verify that the JWT in the Authorization parameter matches the actual app. For details, please refer to Generating a JWT Based on a Service Account.

Generate a new JWT and then send the message.

[h2]80200003 Access Token Expired

Message

Access token expired.

Symptom

The access token has expired.

Possible causes

The access token has expired.

Solution

Generate a new JWT as prompted by the response and then send the request. For details, please refer to Generating a JWT Based on a Service Account.

[h2]80200005 JWT Expired

Message

Jwt token expired.

Symptom

The JWT has expired.

Possible causes

The JWT has expired.

Solution

Generate a new JWT as prompted by the response and then send the request. For details, please refer to Generating a JWT Based on a Service Account.

[h2]80300002 Current App Does Not Have Permission to Send Messages

Message

No permission to send message to these tmIDs.

Symptom

The current app does not have permission to send messages.

Possible causes

  1. Push Kit has not been enabled.

  2. ClientId is not an app-level client ID.

Solution

  1. Sign in to AppGallery Connect and ensure that Push Kit has been enabled. For details, please refer to Enabling Push Kit.

  2. Ensure that ClientId is an app-level client ID. For details, please refer to Guide.

[h2]80300007 All Tokens Are Invalid

Message

All the tokens are invalid.

Symptom

All tokens are invalid.

Possible causes

  1. In principle, the tokens for different apps on the same device are distinct. However, the same token value might accidentally be passed during actual operations.

  2. The app package name and app ID configured in the client app do not match those applied for in AppGallery Connect.

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

Solution

Rectify the sending failure based on the response, which might be one of the following:

  1. Ensure that you do not pass push tokens belonging to other apps.

  2. Ensure that the app package name and app ID configured in the client app match those applied for in AppGallery Connect.

  3. After the device OS is upgraded to HarmonyOS NEXT, regenerate a push token and use request body parameters of the HarmonyOS NEXT version to send the message request.

    Use the v1 request URL (https://push-api.cloud.huawei.com/v1/[clientId]/messages:revoke) to send the REST API request.

    You are advised to call the getToken API upon app launch. If the push token of the device changes, report the change to your app server in a timely manner.

[h2]80300010 Number of Tokens in Message Body Exceeds Default Value

Message

token count should within {0} and {1}.

Symptom

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

Possible causes

The number of tokens in the message body exceeds the default value (1000).

Solution

Check the number of tokens as prompted by the response. If the token count exceeds the single-request limit, split and send messages in batches.

[h2]80300017 Tokens in Token List Belong to Multiple Apps

Message

Token app count should not exceed 1.

Symptom

Tokens in the token list belong to multiple apps.

Possible causes

Tokens in the token list are generated by multiple apps.

Solution

Verify that the tokens in the token list are generated by the same app.

[h2]80300028 App Corresponding to the Token Is Different from That Corresponding to ClientId

Message

Token app mismatch with specify app.

Symptom

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

Possible causes

  1. In principle, the tokens for different apps on the same device are distinct. However, the same token value might accidentally be passed during actual operations.

  2. The app package name and app ID configured in the client app do not match those applied for in AppGallery Connect.

Solution

Rectify the fault as prompted by the response:

  1. Ensure that you do not pass push tokens belonging to other apps.

  2. Ensure that the app package name and app ID configured in the client app match those applied for in AppGallery Connect.

[h2]80300032 No Permission to Revoke Messages

Message

No permission to revoke messages.

Symptom

No permission to revoke messages.

Possible causes

No permission to revoke messages.

Solution

Revoke messages based on both the token and notifyId.

[h2]80000001 Internal System Error

Message

CommonService Error.

Symptom

Internal system error.

Possible causes

An unknown error occurred.

Solution

Submit a ticket online.