简体   繁体   English

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

[英]Android gcm notification payload vs data payload?

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

Reading on the link you send it is explained under 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. 如果要在消息中包含有效内容,则使用data参数包含自定义键/值对。 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. 带有预定义选项的notification参数指示如果客户端应用程序在Android上实现GCMListenerService,或者通知消息发送到iOS设备,则GCM将代表客户端应用程序显示消息。 This applies for both HTTP and XMPP. 这适用于HTTP和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. 在这种情况下,GCM处理显示通知有效负载,客户端应用程序处理数据有效负载。

See the Server Reference for details on sending and receiving messages. 有关发送和接收消息的详细信息,请参阅服务器参考

You may find this explanation more helpful 您可能会发现此解释更有帮助

Use scenario 使用场景

Notification: GCM automatically displays the message to end user devices on behalf of the client app. 通知:GCM代表客户端应用自动向最终用户设备显示消息。 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. 数据消息只有自定义键/值对。

How to send 如何发送

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 https://developers.google.com/cloud-messaging/concept-options?hl=en

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM