小编Sac*_*rma的帖子

如何从C#Console应用程序发送通知

我想创建控制台应用程序,用于通过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() + "&registration_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)

c# firebase-cloud-messaging

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c# ×1

firebase-cloud-messaging ×1