Publishing an Application Message (Deprecated)
Function
Sending an Application Message
URI
POST /v2/{project_id}/notifications/endpoints/{endpoint_urn}/publish
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
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. |
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
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
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
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
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
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.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot