Skip to content

Instantly share code, notes, and snippets.

What would you like to do? Push Notifications Send Through C#
public class ExpoPushHelper
public static dynamic SendPushNotification(string ExpoToken)
dynamic body = new
to = ExpoToken,
title = "hello",
body = "world",
sound = "default",
data = new { some = "daaaata" }
string response = null;
using (WebClient client = new WebClient())
client.Headers.Add("accept", "application/json");
client.Headers.Add("accept-encoding", "gzip, deflate");
client.Headers.Add("Content-Type", "application/json");
response = client.UploadString("", JsonExtensions.ToJson(body));
var json = JsonExtensions.FromJson<dynamic>(response);
return json;
Copy link

danparker276 commented Jul 25, 2018

I had an error which wasn't decoded with webclient like this because expo sent back as gzip.
I added this override of webclient and it worked to get the correct response
From here:

` class MyWebClient : WebClient


    protected override WebRequest GetWebRequest(Uri address)


        HttpWebRequest request = base.GetWebRequest(address) as HttpWebRequest;

        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

        return request;



Copy link

danparker276 commented Aug 17, 2018

Also, another thing I found I had to do was add this for emojis
client.Encoding = System.Text.Encoding.UTF8;

after you create the client

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment