为什么Android的C2DM推送消息并不总是到达? [英] Why do Android C2DM push messages not always arrive?

查看:114
本文介绍了为什么Android的C2DM推送消息并不总是到达?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经建立了一个有效的C2DM应用程序,通常它工作得很好,并推邮件到达快。不过,我发现,相当有规律,当我第一次启动应用程序,或将其带回关注,消息未送达。

I've built a functioning C2DM app and generally it works very well, and the push messages arrive fast. However I find that fairly regularly when I first start the app or bring it back to focus, messages do not arrive.

他们肯定发送成功(我得到一个200响应)和消息格式肯定是正确的(发送相同的消息后正常工作)。失败可以持续少数分钟,然后突然它开始再次合作,以及此后工作始终。

They are definitely sent successfully (I get a 200 response) and the message format is certainly right (sending the same message later works fine). The failure can last for a small number of minutes, and then suddenly it starts working again, and works consistently thereafter.

就开始工作然而,即使后,上了年纪的消息显然已消失,永远不会到达。这些消息肯定没有到达 - 我有大量的日志记录,突出到达的任何C2DM消息

However even after it starts working, the older messages have apparently disappeared and never arrive. The messages are definitely not arriving - I have extensive logging that highlights any C2DM messages that arrive.

我充分认识到C2DM将永远无法保证送货,所以我希望一些消息会失败,但在我的经验,在某些情况下,这是行不通的。我明明想明白,如果那是我做错了我的应用程序,或者C2DM服务本身。

I'm fully aware that C2DM will never guarantee delivery, so I expect some messages will fail, but in my experience, on some occasions, it just doesn't work. I obviously want to understand if that is something I am doing wrong in my app, or the C2DM service itself.

什么会导致C2DM失败将邮件传递? 如果邮件无法送达,为什么是C2DM服务器不会再从队列尝试? 相关 - 我应该得到一个新的注册ID,只有当应用程序启动第一次,或者每一个应用程序启动时刷新呢?我目前正在做后期(在应用程序,而不是活动)。

What could cause C2DM to fail to deliver messages? If messages cannot be delivered, why is the C2DM server not trying again from its queue? Related - should I get a new Registration ID only when the app starts the first time, or refresh it each time the app starts? I currently do the latter (in the Application, not an Activity).

推荐答案

我意识到我犯了一个男生的错误。我重新注册与C2DM每一个应用程序启动时。这个过程有时需要相当多的几秒钟,在这段时间内应用程序将不会收到发送到旧注册ID推送消息。这就解释了为什么推送消息是特别有可能无法在启动应用程序后,立即收到。

I realised I made a schoolboy error. I was re-registering with C2DM every time the app started. That process sometimes takes quite a few seconds, and during that time the app will not receive push messages sent to the old registration ID. This explains why push messages were particularly likely to fail to be received immediately after starting the app.

的解决方案是,以确保注册ID只请求,如果应用程序没有已经有一个。 push消息是现在的工作更加可靠。

The solution was to ensure the registration ID is only requested if the app does not already have one. Push messages are now working much more reliably.

这篇关于为什么Android的C2DM推送消息并不总是到达?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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