Skip to content

Instantly share code, notes, and snippets.

@rbravo
Last active July 24, 2021 06:42
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save rbravo/092dda13daf769b031c70d363aaf738d to your computer and use it in GitHub Desktop.
Save rbravo/092dda13daf769b031c70d363aaf738d to your computer and use it in GitHub Desktop.
Expo.io 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("https://exp.host/--/api/v2/push/send", JsonExtensions.ToJson(body));
}
var json = JsonExtensions.FromJson<dynamic>(response);
return json;
}
}
@danparker276
Copy link

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