Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Publishing an Application Message (Deprecated)

Updated on 2025-02-13 GMT+08:00

Function

Sending an Application Message

URI

POST /v2/{project_id}/notifications/endpoints/{endpoint_urn}/publish

Table 1 Path Parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Specifies the project ID.For details about how to obtain the project ID, see Obtaining the Project ID.

endpoint_urn

Yes

String

Specifies the unique resource identifier of the endpoint. To obtain it, see Querying the Endpoints of an Application.

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Specifies a user token.

It can be obtained by calling an IAM API. The value of X-Subject-Token in the response header is the user token.

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

message

No

String

Select either message or message_structure.

message: Publish an application message.

message_structure: Publish an application message using a message structure.

Specifies the message content. HMS, APNS, and APNS_SANDBOX are supported.

HMS is a platform for developers to push Android messages.

APNS and APNS_SANDBOX are platforms for pushing iOS messages.

Message content for HMS cannot exceed 2 KB.

Message content for APNS and APNS_SANDBOX cannot exceed 4 KB.

For details about the message content format requirements of the push platform, see the format of the application message body.

HMS transparent push message

{ "hps": { "msg": { "type": 1, "body": { "key": "value" } } } }

Huawei notification push message

{ "hps": { "msg": { "type": 3, "body": { "content": "Push message content", "title": "Push message content" }, "action": { "type": 1, "param": { "intent": "#Intent;compo=com.rvr/.Activity;S.W=U;end" } } }, "ext": { "biTag": "Trump", "icon": "http://upload.w.org/00/150pxsvg.png" } } }

Apple platform message { "aps": { "alert": "hello world" } }

message_structure

No

String

Specifies the message content. HMS, APNS, and APNS_SANDBOX are supported.

HMS is a platform for developers to push Android messages.

APNS and APNS_SANDBOX are platforms for pushing iOS messages.

Message content for HMS cannot exceed 2 KB.

Message content for APNS and APNS_SANDBOX cannot exceed 4 KB.

For details about the message content format requirements of the push platform, see the format of the application message body.

HMS transparent push message

{ "HMS": { "hps": { "msg": { "type": 1, "body": { "key": "value" } } } } }

Huawei notification push message

{ "HMS": { "hps": { "msg": { "type": 3, "body": { "content": "Push message content", "title": "Push message content" }, "action": { "type": 1, "param": { "intent": "#Intent;compo=com.rvr/.Activity;S.W=U;end" } } }, "ext": { "biTag": "Trump", "icon": "http://upload.w.org/00/150pxsvg.png" } } } }

Apple platform message

{ "APNS": { "aps": { "alert": "hello world" } } }

time_to_live

No

String

Specifies message TTL (counting from the time when you make the sending request).SMN will count the time a message already consumed in the SMN system before forwarding it to the mobile push platform. The message will be forwarded only when the time it consumed in SMN is less than the TTL, and the consumed time is deducted from the TTL. If the consumed time has exceeded the TTL, the message will be discarded.The time period is measured in seconds, and the default TTL is 3600s (one hour). The retention period must be a positive integer less than or equal to 86,400 (3600 x 24).

Default: 3600

Response Parameters

Status code: 200

Table 4 Response body parameters

Parameter

Type

Description

message_id

String

Specifies the message ID, which is unique.

request_id

String

Specifies the request ID, which is unique.

Status code: 400

Table 5 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Status code: 403

Table 6 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Status code: 404

Table 7 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Status code: 500

Table 8 Response body parameters

Parameter

Type

Description

request_id

String

Specifies the request ID, which is unique.

code

String

Specifies the error code.

message

String

Describes the error message.

Example Requests

  • Publishing an application message
    POST https://{SMN_Endpoint}/v2/{project_id}/notifications/endpoints/{endpoint_urn}/publish
    
    {
      "message" : {
        "hps" : {
          "msg" : {
            "action" : {
              "param" : {
                "intent" : "#Intent;compo=com.HC.SmnAppPush.defaultAction/.Activity;S.W=U;end"
              },
              "type" : 1
            },
            "body" : {
              "title" : "hello world",
              "content" : "hello world"
            },
            "type" : 3
          }
        }
      },
      "time_to_live" : 3600
    }
  • Publishing an application message using a message structure
    POST https://{SMN_Endpoint}/v2/{project_id}/notifications/endpoints/{endpoint_urn}/publish
    
    {
      "message" : {
        "HMS" : {
          "hps" : {
            "msg" : {
              "action" : {
                "param" : {
                  "intent" : "#Intent;compo=com.HC.SmnAppPush.defaultAction/.Activity;S.W=U;end"
                },
                "type" : 1
              },
              "body" : {
                "title" : "hello world",
                "content" : "hello world"
              },
              "type" : 3
            }
          }
        }
      },
      "time_to_live" : 3600
    }

Example Responses

Status code: 200

OK

{
  "request_id" : "6a63a18b8bab40ffb71ebd9cb80d0085",
  "message_id" : "bf94b63a5dfb475994d3ac34664e24f2"
}

Status Codes

Status Code

Description

200

OK

400

Bad Request

403

Unauthorized

404

Not Found

500

Internal Server Error

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback