方法来想,如果C2DM连接 [英] Ways to guess if C2DM is connected

查看:174
本文介绍了方法来想,如果C2DM连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图把最好的猜测估计为C2DM消息是否可以接受。

I'm trying to place a best guess estimate as to whether C2DM messages can be received.

我已经创建依赖于信息推送到手机,而它是物理上不可访问的应用程序。据我所知,C2DM不能保证交货,但我至少想知道,当一个消息的传递甚至有可能;当它不是我们退回到我们自己的推送服务(和实际上可以说,当我们连接)。

I've created an application that relies on pushing information to a phone while it is physically inaccessible. I understand that C2DM isn't guaranteed delivery, but I'd at least like to know when the delivery of a message is even possible; when it isn't we fall back to our own push service (and can actually tell when we're connected).

我注意到C2DM仍会发出身份验证令牌时,即使不登录谷歌帐户;消息似乎仍然在这种情况下交付,即使它说,他们不应该。如果GTalk的未连接(防火墙或其他原因),请求身份验证令牌时,将返回完全没有反应。验证令牌返回给应用程序时,手机处于飞行模式。这意味着它不是简单的检查,如果一个网络连接。我找不到,如果GTalk的记录在检查的可靠方法。

I've noticed C2DM on android will still issue auth tokens even when there is not a logged in google account; messages still seem to be delivered in this instance even though it's stated that they shouldn't be. If GTalk isn't connected (firewall or other reasons), no response at all is returned when requesting an auth token. Auth tokens are returned to the application when the phone is in airplane mode. This means it's not as simple as checking if an internet is available. I can't find a reliable way of checking if GTalk is logged in.

此外,我并不需要的保证的邮件的传递,但我至少想知道是否交付甚至的可能的。有没有人有有趣的解决方案?

Again, I don't need to guarantee the delivery of messages, but I'd at least like to know if delivery is even possible. Does anyone have interesting solutions?

推荐答案

前去观看这段视频,这是一个谷歌I / C2DM左右,如何使用它,以及如何工作Ø谈话。 AFAIK,你可以不知道,如果它的连接与否。也许大部分的时间,他们甚至不知道(直到他们有传递消息和失败)。

Go watch this video, it's a Google I/O talk about C2DM, how to use it and how it works. AFAIK, you can't know if it's connected or not. Probably most of the time they don't even know (until they have to deliver a message and fail).

不过,强烈建议(在视频为好),你不通过C2DM发送重要的数据(如消息可能会丢失)。该服务只应作为网络痒(具有足迹尽可能小)。您的应用程序应该被惊醒过来,这痒痒的,它应该开始获取所需信息的本身

However, it is highly recommended (in the video as well) that you do not send important data through C2DM (as messages can get lost). The service should only be used as a "network tickle" (with a footprint as small as possible). Your application should be woken up by this tickle and it should start fetching the information it needs itself.

现在,如果实现这种方式,它应该很容易实现轮询机制。既然你已经脱离了实际的信息检索的挠痒痒,你可以触发检索每过一段时间如果没有痒痛。

Now, if you implement it this way, it should be easy to implement a polling mechanism. Since you already separated the "tickle" from the actual information retrieval, you can just trigger the retrieval every once in a while if there's no tickle.

东西可以做,以检查是否C2DM连接是这样一个平:

Something you can do to check whether C2DM is connected is something like a ping:

  1. 通过C2DM信息发送到手机
  2. 在该应用程序接收(或不接收)的消息,并发送一个傍回你的服务器
  3. 对于傍的时间predetermined量标记设备为脱机之前,服务器等待(1-2分钟,我会说)。

编辑:靠GTalk的是不可行的。 GTalk的依赖C2DM就像你的应用程序,它没有任何额外。此外,GTalk的并不是在所有设备上present。我不知道怎么的GTalk应用程序确定它是否是离线或没有(这不是开源的,不幸的是),但我想这只是尝试ping服务器和失败。

relying on GTalk is not feasible. GTalk relies on C2DM just like your app, it doesn't have anything "extra". Also, GTalk is not present on all devices. I'm not sure how the GTalk app determines whether it's offline or not (it's not open source, unfortunately), but I'd guess it just tries to ping a server and fails.

这篇关于方法来想,如果C2DM连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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