Android gcm 通知负载与数据负载?

Android gcm notification payload vs data payload?

根据 https://developers.google.com/cloud-messaging/server-ref gcm 消息可以有通知负载 or/and 数据负载 这两者有什么区别?

阅读 link 您发送的内容在 Payload section

下有解释

Payload

Optional. If you are including a payload in the message, you use the data parameter to include your custom key/value pairs. The client app handles the data payload for display or other processing purposes.

The notification parameter with predefined options indicates that GCM will display the message on the client app’s behalf if the client app implements GCMListenerService on Android, or if the notification message is sent to an iOS device. This applies for both HTTP and XMPP.

The app server can send a message including both notifications and data payloads. In such cases, GCM handles displaying the notification payload and the client app handles the data payload.

See the Server Reference for details on sending and receiving messages.

您可能会发现此解释更有帮助

使用场景

Notification: GCM automatically displays the message to end user devices on behalf of the client app. Notifications have a pre-defined set of user-visible keys.

Data: Client app is responsible for processing data messages. Data messages have only custom key/value pairs.

如何发送

Notification: Set notification payload. May have optional data payload. Always collapsible.

Data: Set data payload only. Can be either collapsible or non-collapsible.

https://developers.google.com/cloud-messaging/concept-options?hl=en