GCM 推送通知不通过代理 [英] GCM push notifications not coming through proxy

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

问题描述

我正在为我的课程项目(类似于 Snapchat)开发一个小应用程序,它允许人们发送和接收图片和视频.我正在使用名为 Parse 的 BaaS,它使用 GCM 来传递推送通知.但是,问题是我的校园使用代理网络,因此许多应用程序(WhatsApp、Instagram)无法运行,而某些应用程序(Snapchat)可以运行,但无法发送通知.我的应用程序也是如此.

I'm developing a small app for my course project (similar to Snapchat) that allows one to send and receive pictures and videos. I'm using a BaaS called Parse which uses GCM to deliver push notifications. However, the problem is that my campus uses a proxy network due to which numerous apps do not work (WhatsApp, Instagram) while some apps (Snapchat) work but their notifications are not delivered. Same is the case with my app.

假设我对代理网络没有任何影响并且蜂窝网络没有​​选择,是否有任何可能的方法来克服这个问题.

Is there any possible way to overcome this problem assuming I do not have any influence over the proxy network and cellular network is out of options.

推荐答案

这完全取决于您的校园网络访问策略.如果您的校园代理防火墙不提供对这些站点的访问,您就不能这样做.但是,您可以要求他们允许这些 URL 通过他们的代理防火墙.

It all depends on your campus network access policy. You cant do if your campus proxy firewall doesnt provide access to these sites. However, you can ask them to allow these URL through their proxy firewall.

或者,您可以通过在代码中添加行来使用其他一些外部代理服务器

Or, simply you can use some other external proxy server by adding lines in your code

System.setProperty("https.proxyHost", "");System.setProperty("https.proxyPort", "");

您尝试连接 Google API 的位置.假设你正在使用这样的东西,

where you are trying to connect the Google APIs. Say if you are using something like this,

URL url = new URL("https://android.googleapis.com/gcm/send");
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setRequestProperty("Authorization", "key="+<your api key>);

在您尝试连接到 Google API 的这些行之前,添加代理设置行,即上述两行.另外,尝试使用您的校园代理以及其他一些外部代理,您会知道问题是否与您的校园代理有关.

Before these lines where you attempting to connect to Google API, add the proxy setting lines, the above two lines. Also, try with your campus proxy as well some other external proxy, you will come to know issue is with your campus proxy or not.

试试这个,希望这能帮助你解决问题..!!!!!!

Try this, hope this helps with your problem..!!!!!

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

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