update readme.

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi Wu 2016-10-23 22:01:08 +08:00
parent 81f37465b0
commit f42d9e2ee3
1 changed files with 49 additions and 48 deletions

View File

@ -363,57 +363,58 @@ See more example about [iOS](#ios-example) or [Android](#android-example).
Request body must has a notifications array. The following is a parameter table for each notification.
|name|type|description|required|note|
|-------|-------|--------|--------|---------|
|tokens|string array|device tokens|o||
|platform|int|platform(iOS,Android)|o|1=iOS, 2=Android|
|message|string|message for notification|o||
|title|string|notification title|-||
|priority|string|Sets the priority of the message.|-|`normal` or `high`|
|content_available|bool|data messages wake the app by default.|-||
|sound|string|sound type|-||
|data|string array|extensible partition|-||
|api_key|string|Android api key|-|only Android|
|to|string|The value must be a registration token, notification key, or topic.|-|only Android|
|collapse_key|string|a key for collapsing notifications|-|only Android|
|delay_while_idle|bool|a flag for device idling|-|only Android|
|time_to_live|uint|expiration of message kept on GCM storage|-|only Android|
|restricted_package_name|string|the package name of the application|-|only Android|
|dry_run|bool|allows developers to test a request without actually sending a message|-|only Android|
|notification|string array|payload of a GCM message|-|only Android. See the [detail](#android-notification-payload)|
|expiration|int|expiration for notification|-|only iOS|
|apns_id|string|A canonical UUID that identifies the notification|-|only iOS|
|topic|string|topic of the remote notification|-|only iOS|
|badge|int|badge count|-|only iOS|
|category|string|the UIMutableUserNotificationCategory object|-|only iOS|
|alert|string array|payload of a iOS message|-|only iOS. See the [detail](#ios-alert-payload)|
| name | type | description | required | note |
|-------------------------|--------------|---------------------------------------------------------------------------------------------------|----------|---------------------------------------------------------------|
| tokens | string array | device tokens | o | |
| platform | int | platform(iOS,Android) | o | 1=iOS, 2=Android |
| message | string | message for notification | o | |
| title | string | notification title | - | |
| priority | string | Sets the priority of the message. | - | `normal` or `high` |
| content_available | bool | data messages wake the app by default. | - | |
| sound | string | sound type | - | |
| data | string array | extensible partition | - | |
| retry | int | retry send notification if fail response from server. Value must be small than `max_retry` field. | - | |
| api_key | string | Android api key | - | only Android |
| to | string | The value must be a registration token, notification key, or topic. | - | only Android |
| collapse_key | string | a key for collapsing notifications | - | only Android |
| delay_while_idle | bool | a flag for device idling | - | only Android |
| time_to_live | uint | expiration of message kept on GCM storage | - | only Android |
| restricted_package_name | string | the package name of the application | - | only Android |
| dry_run | bool | allows developers to test a request without actually sending a message | - | only Android |
| notification | string array | payload of a GCM message | - | only Android. See the [detail](#android-notification-payload) |
| expiration | int | expiration for notification | - | only iOS |
| apns_id | string | A canonical UUID that identifies the notification | - | only iOS |
| topic | string | topic of the remote notification | - | only iOS |
| badge | int | badge count | - | only iOS |
| category | string | the UIMutableUserNotificationCategory object | - | only iOS |
| alert | string array | payload of a iOS message | - | only iOS. See the [detail](#ios-alert-payload) |
### iOS alert payload
|name|type|description|required|note|
|-------|-------|--------|--------|---------|
|action|string|The label of the action button. This one is required for Safari Push Notifications.|-||
|action-loc-key|string|If a string is specified, the system displays an alert that includes the Close and View buttons.|-||
|launch-image|string|The filename of an image file in the app bundle, with or without the filename extension.|-||
|loc-args|array of strings|Variable string values to appear in place of the format specifiers in loc-key.|-||
|loc-key|string|A key to an alert-message string in a Localizable.strings file for the current localization.|-||
|title-loc-args|array of strings|Variable string values to appear in place of the format specifiers in title-loc-key.|-||
|title-loc-key|string|The key to a title string in the Localizable.strings file for the current localization.|-||
| name | type | description | required | note |
|----------------|------------------|--------------------------------------------------------------------------------------------------|----------|------|
| action | string | The label of the action button. This one is required for Safari Push Notifications. | - | |
| action-loc-key | string | If a string is specified, the system displays an alert that includes the Close and View buttons. | - | |
| launch-image | string | The filename of an image file in the app bundle, with or without the filename extension. | - | |
| loc-args | array of strings | Variable string values to appear in place of the format specifiers in loc-key. | - | |
| loc-key | string | A key to an alert-message string in a Localizable.strings file for the current localization. | - | |
| title-loc-args | array of strings | Variable string values to appear in place of the format specifiers in title-loc-key. | - | |
| title-loc-key | string | The key to a title string in the Localizable.strings file for the current localization. | - | |
See more detail about [APNs Remote Notification Payload](https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1).
### Android notification payload
|name|type|description|required|note|
|-------|-------|--------|--------|---------|
|icon|string|Indicates notification icon.|-||
|tag|string|Indicates whether each notification message results in a new entry on the notification center on Android.|-||
|color|string|Indicates color of the icon, expressed in #rrggbb format|-||
|click_action|string|The action associated with a user click on the notification.|-||
|body_loc_key|string|Indicates the key to the body string for localization.|-||
|body_loc_args|string|Indicates the string value to replace format specifiers in body string for localization.|-||
|title_loc_key|string|Indicates the key to the title string for localization.|-||
|title_loc_args|string|Indicates the string value to replace format specifiers in title string for localization.|-||
| name | type | description | required | note |
|----------------|--------|-----------------------------------------------------------------------------------------------------------|----------|------|
| icon | string | Indicates notification icon. | - | |
| tag | string | Indicates whether each notification message results in a new entry on the notification center on Android. | - | |
| color | string | Indicates color of the icon, expressed in #rrggbb format | - | |
| click_action | string | The action associated with a user click on the notification. | - | |
| body_loc_key | string | Indicates the key to the body string for localization. | - | |
| body_loc_args | string | Indicates the string value to replace format specifiers in body string for localization. | - | |
| title_loc_key | string | Indicates the key to the title string for localization. | - | |
| title_loc_args | string | Indicates the string value to replace format specifiers in title string for localization. | - | |
See more detail about [GCM server reference](https://developers.google.com/cloud-messaging/http-server-ref#send-downstream).
@ -518,11 +519,11 @@ Add other fields which user defined via `data` field.
Error response message table:
|status code|message|
|-------|-------|
|400|Missing `notifications` field.|
|400|Notifications field is empty.|
|400|Number of notifications(50) over limit(10)|
| status code | message |
|-------------|--------------------------------------------|
| 400 | Missing `notifications` field. |
| 400 | Notifications field is empty. |
| 400 | Number of notifications(50) over limit(10) |
Success response: