Last active
July 24, 2021 06:42
-
-
Save rbravo/092dda13daf769b031c70d363aaf738d to your computer and use it in GitHub Desktop.
Expo.io Push Notifications Send Through C#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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