我想创建控制台应用程序,用于通过Goolge Firebase Notifications向不同的移动设备发送通知,
我已经看到了使用FCM(Firebase云消息传递)通过C#发送推送到Android的代码
我收到状态码为500的内部服务器错误
try{
string url = @"https://fcm.googleapis.com/fcm/send";
WebRequest tRequest = WebRequest.Create(url);
tRequest.Method = "post";
tRequest.ContentType = "application/json";
string postData = "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message=" + "This is the message" + "&data.time=" + System.DateTime.Now.ToString() + "®istration_id=" + deviceId + "";
var data = new
{
to = deviceId,
notification = new
{
body = "This is the message",
title = "This is the title"
}
};
string jsonss = Newtonsoft.Json.JsonConvert.SerializeObject(data);
Byte[] byteArray = Encoding.UTF8.GetBytes(jsonss);
tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
tRequest.Headers.Add(string.Format("Sender: id={0}", …Run Code Online (Sandbox Code Playgroud)