You can revoke messages sent through simple or template push by using the message ID, and those sent through batch or group push by using the task ID. Only messages from the past 7 days are eligible for revocation.
Revoke by message ID
This function allows you to revoke messages sent through simple or template push.
Request parameters
Parameter name | Type | Required | Example | Description |
messageId | String | Yes | 1578807462788 | Business message ID, user-defined, used to uniquely identify the message in the business system. |
targetId | String | Yes | user1024 | Target ID. If the original message was pushed by device dimension, the target ID is the device ID; if pushed by user dimension, the target ID is the user ID. |
Response parameters
Parameter name | Type | Example | Description |
RequestId | String | B589F4F4-CD68-3CE5-BDA0-6597F33E23916512 | Request ID |
ResultCode | String | OK | Request result code |
ResultMessage | String | param is invalid | Request error description |
PushResult | JSON | Request result | |
Success | boolean | true | Request status. The |
ResultMsg | String | param is invalid | Request error content. The |
Usage example
DefaultProfile.addEndpoint("cn-hangzhou", "mpaas", "mpaas.cn-hangzhou.aliyuncs.com");
// Create DefaultAcsClient instance and initialize
// Alibaba Cloud account AccessKey has access privileges for all APIs, which is very risky. We strongly recommend that you create and use a RAM user for API access or daily operations. Please log on to the RAM console to create a RAM user
// This example illustrates saving the AccessKey and AccessKeySecret in environment variables. You can also save them in the configuration file based on your business requirements
// We strongly recommend that you do not specify the AccessKey ID and AccessKey secret in code, as there is a risk of key leakage
// It is recommended to complete the environment variable configuration first
String accessKeyId = System.getenv("MPAAS_AK_ENV");
String accessKeySecret = System.getenv("MPAAS_SK_ENV");
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou", // Region ID
accessKeyId,
accessKeySecret);
IAcsClient client = new DefaultAcsClient(profile);
RevokePushMessageRequest request = new RevokePushMessageRequest();
request.setAppId("ONEX570DA89211720");
request.setWorkspaceId("test");
request.setMessageId("console_1624516744112"); // Business message ID
request.setTargetId("mpaas_push_demo"); // Target ID
RevokePushMessageResponse response;
try {
response = client.getAcsResponse(request);
System.out.println(response.getResultCode());
System.out.println(response.getResultMessage());
} catch (ClientException e) {
e.printStackTrace();
}Revoke by task ID
This function allows you to revoke messages sent through batch or group push.
Request parameters
Parameter name | Type | Required | Example | Description |
taskId | String | Yes | 20842863 | Push task ID, which can be queried in the console push task list. |
Response parameters
Parameter name | Type | Example | Description |
RequestId | String | B589F4F4-CD68-3CE5-BDA0-6597F33E23916512 | Request ID |
ResultCode | String | OK | Request result code |
ResultMessage | String | param is invalid | Request error description |
PushResult | JSON | Request result | |
Success | boolean | true | Request status. The |
ResultMsg | String | param is invalid | Request error content. The |
Usage example
DefaultProfile.addEndpoint("cn-hangzhou", "mpaas", "mpaas.cn-hangzhou.aliyuncs.com");
// Create DefaultAcsClient instance and initialize
// Alibaba Cloud account AccessKey has access privileges for all APIs, which is very risky. We strongly recommend that you create and use a RAM user for API access or daily operations. Please log on to the RAM console to create a RAM user
// This example illustrates saving the AccessKey and AccessKeySecret in environment variables. You can also save them in the configuration file based on your business requirements
// We strongly recommend that you do not specify the AccessKey ID and AccessKey secret in code, as there is a risk of key leakage
// It is recommended to complete the environment variable configuration first
String accessKeyId = System.getenv("MPAAS_AK_ENV");
String accessKeySecret = System.getenv("MPAAS_SK_ENV");
DefaultProfile profile = DefaultProfile.getProfile(
"cn-hangzhou", // Region ID
accessKeyId,
accessKeySecret);
IAcsClient client = new DefaultAcsClient(profile);
RevokePushTaskRequest request = new RevokePushTaskRequest();
request.setAppId("ONEX570DA89211720");
request.setWorkspaceId("test");
request.setTaskId("20842863"); // Push task ID
RevokePushTaskResponse response;
try {
response = client.getAcsResponse(request);
System.out.println(response.getResultCode());
System.out.println(response.getResultMessage());
} catch (ClientException e) {
e.printStackTrace();
}