2012年8月25日 星期六

using plain text

If you are using plain text instead of JSON, the message fields must be set as HTTP parameters sent in the body, and their syntax is slightly different, as described below:


Field Description
registration_id Must contain the registration ID of the single device receiving the message. Required.
collapse_key Same as JSON (see previous table). Optional.
data.<key> Payload data, expressed as parameters prefixed with data. and suffixed as the key. For instance, a parameter of data.score=3x1 would result in an intent extra named score whose value is the string 3x1. There is no limit on the number of key/value parameters, though there is a limit on the total size of the message. Note that the key cannot be a reserved word (from or any word starting with google.). Optional.
delay_while_idle Should be represented as 1 or true for true, anything else for false. Optional. The default value is false.
time_to_live Same as JSON (see previous table). Optional.


If you want to test your request (either JSON or plain text) without delivering the message to the devices, you can set an optional HTTP parameter called dry_run with the value true. The result will be almost identical to running the request without this parameter, except that the message will not be delivered to the devices. Consequently, the response will contain fake IDs for the message and multicast fields (see Response format).

沒有留言:

張貼留言