Push messages to Android devices

更新时间:
复制 MD 格式

Call the PushMessageToAndroid operation to push messages to Android devices.

Description

This operation sends messages to online devices by default. To send messages that are stored for offline devices, use the advanced Push API.

Test

You can test this operation in OpenAPI Explorer without the need to calculate signatures. Upon successful execution, OpenAPI Explorer automatically generates SDK code examples.

Request parameters

Name

Type

Required

Example value

Description

Action

String

Yes

PushMessageToAndroid

PushMessageToAndroid

PushMessageToAndroid.

AppKey

Long

Yes

23267207

AppKey details

Body

String

Yes

my body

The message content.

Target

String

Yes

ALL

The push target. Valid values:

  • DEVICE: Pushes messages based on devices.

  • ACCOUNT: Pushes messages based on accounts.

  • ALIAS: Pushes messages based on aliases.

  • TAG: Pushes messages based on tags.

  • ALL: Pushes messages to all devices.

TargetValue

String

Yes

all

The value of this parameter depends on the `Target` parameter. Use commas (,) to separate multiple values. If you exceed the limit for a value, send the message in multiple pushes.

  • If `Target` is set to `DEVICE`, specify device IDs, such as

    deviceid111,deviceid1111

    . You can specify up to 1,000 device IDs.
  • If `Target` is set to `ACCOUNT`, specify accounts, such as

    account111,account222

    . You can specify up to 1,000 accounts.
  • If `Target` is set to `ALIAS`, specify aliases, such as

    alias111,alias222

    . You can specify up to 1,000 aliases.
  • If `Target` is set to `TAG`, specify one or more tags. For more information about the format, see Tag format.
  • If `Target` is set to `ALL`, set the value to all.

Title

String

Yes

my title

The message title.

JobKey

String

No

123

The custom ID for the push task. If you specify a `JobKey`, this field is included in the receipt log. For more information, see Receipt log.

Return Data

Name

Type

Example

Description

MessageId

String

501029

The message ID of a single push.

RequestId

String

9998B3CC-ED9E-4CB3-A8FB-DCC61296BFBC

The request ID.

Examples

Sample request

http(s)://cloudpush.aliyuncs.com/?Action=PushMessageToAndroid
&AppKey=23267207
&Body=my body
&Target=ALL
&TargetValue=all
&Title=my title
&<Common request parameters>

Sample success response

XML format

<PushMessageToAndroidResponse>
      <RequestId>9998B3CC-ED9E-4CB3-A8FB-DCC61296BFBC</RequestId>
      <MessageId>501029</MessageId>
</PushMessageToAndroidResponse>

JSON format

{
  "RequestId": "9998B3CC-ED9E-4CB3-A8FB-DCC61296BFBC",
  "MessageId": "501029"
}

Error codes

For a list of error codes, see the Error Center.