我想创建控制台应用程序,用于通过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) 我已经构建了一个web api,它将成为AngularJs,IOS和Android前端应用程序的后端.
现在我需要在例如产品更新时将通知从我的web api推送到前端应用程序.
我正在考虑使用SignalR以实时方式推送通知,但如果其他用户处于脱机状态则无用.
现在我打算使用FCM推送通知,所以你可以请你回答我的问题
如何将我的web api与FCM集成,以及在推送通知时使用FCM可以获得哪些好处?
PS
我将不胜感激任何将asp.net web api与FCM集成的参考资料
c# push-notification asp.net-web-api firebase-cloud-messaging