GCM发送通知到脱机设备 [英] Send GCM notification to an offline device

查看:172
本文介绍了GCM发送通知到脱机设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我发送通知到设备,而设备离线我得到的是这样的:

If I am sending a notification to a device, and that device is offline I get something like:

错误:不可用

和我必须重新发送。

我的问题是:

请问GCM服务器保留这些通知在队列中,并自动重发时,该设备在线?或者,它必须由我完全处理。

Will the GCM server keep these notifications in a queue and automatically resend when the device is online? Or it must be completely handled by me.

因为如果GCM服务器将它们自动发送(一次设备在线),直至实际发送通知,我的服务器假定他们已经发送。如何跟踪时,通知被成功怨恨的时候?

Because if the GCM server is going to send them automatically(once the device is online), until it actually sends the notifications, my server assumes they are already sent. How to track the time when the notifications are resent successfully?

我可以在我的服务器端标记,该通知不会通过查看不可用错误信息发送,但根本看不出来如何标记他们作为曾经的GCM发送成功发送通知。

I might mark on my server side that the notifications are not sent by looking at the Unavailable error message but cannot make out how to mark them as sent once the GCM successfully sends the notifications.

感谢您

推荐答案

A / C到文档---当第三方服务器发布消息到GCM和接收消息ID后面,但这并不意味着该消息已经传送到该设备。相反,它意味着它被接受交付。发生了什么被接受后,该信息取决于许多因素。

A/c to documentation--- When a 3rd-party server posts a message to GCM and receives a message ID back, it does not mean that the message was already delivered to the device. Rather, it means that it was accepted for delivery. What happens to the message after it is accepted depends on many factors.

如果该设备已连接,但空闲,该消息仍将马上除非delay_while_idle标志被设置为真递送。否则,它将被存储在GCM服务器,直到该设备是清醒的。而这也正是collapse_key的标志,起到了重要作用:如果已经有存储,等待交付,旧的信息将被丢弃,并且新的消息会取代其位置相同的崩溃键(注册ID)的消息(也就是,旧的消息将被新的被折叠)。但是,如果崩溃键不,无论是新老信息存储的未来交付。

If the device is connected but idle, the message will still be delivered right away unless the delay_while_idle flag is set to true. Otherwise, it will be stored in the GCM servers until the device is awake. And that's where the collapse_key flag plays a role: if there is already a message with the same collapse key (and registration ID) stored and waiting for delivery, the old message will be discarded and the new message will take its place (that is, the old message will be collapsed by the new one). However, if the collapse key is not set, both the new and old messages are stored for future delivery.

请注意:有多少信息可以存储而不塌陷的限制。这限制目前为100。如果达到了极限,所有存储的消息会被丢弃。

Note: There is a limit on how many messages can be stored without collapsing. That limit is currently 100. If the limit is reached, all stored messages are discarded.

这篇关于GCM发送通知到脱机设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆