Skip to content

Added programmatic web proxy configuration for GCM #390

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions PushSharp.Android/Gcm/GcmPushChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void SendNotification(INotification notification, SendNotificationCallbac
//var postData = msg.GetJson();

var webReq = (HttpWebRequest)WebRequest.Create(gcmSettings.GcmUrl);
ConfigureProxy (webReq);
//webReq.ContentLength = postData.Length;
webReq.Method = "POST";
webReq.ContentType = "application/json";
Expand All @@ -70,6 +71,14 @@ public void SendNotification(INotification notification, SendNotificationCallbac
});
}

void ConfigureProxy(HttpWebRequest request)
{
if (gcmSettings.Proxy != null)
{
request.Proxy = gcmSettings.Proxy;
}
}

void requestStreamCallback(IAsyncResult result)
{
var asyncParam = result.AsyncState as GcmAsyncParameters;
Expand Down
2 changes: 2 additions & 0 deletions PushSharp.Android/Gcm/GcmPushChannelSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
using PushSharp.Core;
using System.Net;

namespace PushSharp.Android
{
Expand Down Expand Up @@ -31,6 +32,7 @@ public GcmPushChannelSettings(string optionalSenderID, string senderAuthToken, s
public string SenderID { get; private set; }
public string SenderAuthToken { get; private set; }
public string ApplicationIdPackageName { get; private set; }
public WebProxy Proxy { get; set; }

public bool ValidateServerCertificate { get; set; }

Expand Down