在Android设备连接到WIFI时不要收到GCM消息 [英] Do not receive GCM message while android device being connected to WIFI

查看:215
本文介绍了在Android设备连接到WIFI时不要收到GCM消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

背景



我正在使用Google Cloud Messaging(新的GCM-API,不推荐使用C2DM)来发送发送至同步消息的Android应用程序所有注册的设备。

由于我使用了官方文档,我的客户端实现的工作方式几乎与Google的示例一样。作为服务器,我使用一个运行在本地主机上的简单PHP脚本,其唯一的任务是发送发送同步消息给GCM。



问题



只要我的设备通过UMTS等移动网络连接到互联网,服务器就会向GCM发送通知> GCM在联机时立即向设备推送通知>通知显示在设备)。

但是,当设备连接到WIFI时,不会收到任何GCM消息(尽管Google向我的PHP服务器发送成功消息)。由于以下答案,我已经检查过我的路由器是否阻塞了某些端口,但没有。


即使GCM服务器回复成功,我也有同样的接收推送消息的问题,因为wifi隐私。当我使用我公司的无线网络时,我并没有在手机上收到消息,因为他们被封锁了GCM服务器端口。


有趣的是,我的实施已经与WIFI一起工作...



当从PHP发送GCM消息时Google的回复:

  {
multicast_id:4677038582377051331,
成功:1,
失败:0,
canonical_ids:0,
results:[{message_id:0:1406364179145476%6ce83c64d7d6c7e2}]
}



非常疯狂的发现:



这个问题在我调用从脚本发送GCM消息的PHP脚本时就解决了,因为一切正常。

HINT



同时这个新GCM-API也被弃用!
我现在使用最新的GCM-API (2015年夏季发布) 。自升级以来,我再也没有遇到过这个问题。从我的角度来看,新API包括 InstanceId-API 是非常值得推荐的,至今因为我发现它比旧的GCM更稳定。 已弃用的GCM版

同时这个新GCM-API也被弃用!
我现在正在使用最新的GCM-API (2015年夏季发布)。自升级以来,我再也没有遇到过这个问题。从我的角度来看,新的API,包括 InstanceId-API 是非常值得推荐的,尽可能我发现它比以前的GCM-API更稳定。


Background

I am working on an Android app which uses Google Cloud Messaging (new GCM-API, not deprecated C2DM) for sending send-to-sync messages to all registered devices.

Since I used the official documentation my client implementation works almost exactly the same way like Google´s example. As a server I use a simple PHP script running on localhost whose only task is to send send-to-sync messages to GCM.

The Issue

Everything works fine as long as my devices are connected to the internet through cellular networks like UMTS (server sends notfication to GCM > GCM pushes notifcation to device as soon as it is online > notification is displayed on device).

But when the device is connected to the WIFI no GCM messages will be received anymore (although Google sends a "success"-reply to my PHP server). Due to the following answer I have already checked if my router blocks some ports but it does not.

I had same problem of receiving push messages, even though GCM server replies "Success", because of wifi privacy. When I used my company wifi, I coudn't receive message in mobile, since they were blocked GCM server port.

Interestingly enough my implementation already has been working with WIFI...

Google´s reply when sending GCM message from PHP:

{
    "multicast_id":4677038582377051331,
    "success":1,
    "failure":0,
    "canonical_ids":0,
    "results":[{"message_id":"0:1406364179145476%6ce83c64d7d6c7e2"}]
}


Very crazy finding:

The issue solved itself when I called the PHP script which sends my GCM messages from the smartphone and since that everything works fine.

HINT

Meanwhile this "new" GCM-API is deprecated either! I am using the latest GCM-API (published in summer 2015) now. Since upgrading I have never faced this issue again. The new API, including InstanceId-API is very recommendable from my point of view, as far as I see it is a more stable than old GCM.

解决方案

Deprecated GCM-version

Meanwhile this "new" GCM-API is deprecated either! I am using the latest GCM-API (published in summer 2015) now. Since upgrading I have never faced this issue again. The new API, including InstanceId-API is very recommendable from my point of view, as far as I see it is a more stable than the previous GCM-API.

这篇关于在Android设备连接到WIFI时不要收到GCM消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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