gpt4 book ai didi

android - GCM 云连接服务器 (CCS) 是否存储消息

转载 作者:行者123 更新时间:2023-11-29 01:53:01 25 4
gpt4 key购买 nike

当设备想要通过 CCS 向第三方服务器发送消息时,如果 CSS 无法将消息传送到服务器,它会像 Google Cloud Messaging 那样存储消息,还是通知设备它无法发送,设备上的应用程序负责稍后重新发送?

另外,如果 CCS 确实连接到第 3 方服务器,但发送消息时出现问题,它会通知客户端应用程序错误吗?

最佳答案

基于API of the GoogleCloudMessaging class ,消息将存储在 GCM 服务器中,就像云到设备的消息一样,具体取决于指定的 timeToLive

仅当指定的 timeToLive 为 0 时,CCS 才会在发送消息出现问题时返回错误。

public void send (String to, String msgId, long timeToLive, Bundle data)

Send a "device to cloud" message. The current limits for max storage time and number of outstanding messages per application are documented in the GCM Dev Guide.

Parameters

to string identifying the receiver of the message. For GCM projects IDs the value is SENDER_ID@gcm.googleapis.com. The SENDER_ID should be one of the sender IDs used in register().

msgId ID of the message. This is generated by the application. It must be unique for each message. This allows error callbacks and debugging.

timeToLive If 0, we'll attempt to send immediately and return an error if we're not connected. Otherwise, the message will be queued. As for server-side messages, we don't return an error if the message has been dropped because of TTL—this can happen on the server side, and it would require extra communication.

data key/value pairs to be sent. Values must be String, any other type will be ignored.

Throws

IOException

public void send (String to, String msgId, Bundle data)

Send a "device to cloud" message. The message will be queued if we don't have an active connection for the max interval.

Parameters

to string identifying the receiver of the message. For GCM project IDs the value is SENDER_ID@gcm.googleapis.com. The SENDER_ID should be one of the sender IDs used in register().

msgId ID of the message. This is generated by the application. It must be unique for each message. This allows error callbacks and debugging.

data key/value pairs to be sent. Values must be String—any other type will be ignored.

Throws

IOException

关于android - GCM 云连接服务器 (CCS) 是否存储消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16854301/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com