如何通过.NetParse.com发送API推送消息?(C#)

如何通过.NetParse.com发送API推送消息?(C#),第1张

如何通过.Net / Parse.com发送API推送消息?(C#)

使用.net中的parse运行波纹管代码以进行推送通知。

private bool PushNotification(string pushMessage){    bool isPushMessageSend = false;    string postString = "";    string urlpath = "https://api.parse.com/1/push";    var httpWebRequest = (HttpWebRequest)WebRequest.Create(urlpath);    postString = "{ "channels": [ "Trials"  ], " +          ""data" : {"alert":"" + pushMessage + ""}" +          "}";    httpWebRequest.ContentType = "application/json";    httpWebRequest.ContentLength = postString.Length;    httpWebRequest.Headers.Add("X-Parse-Application-Id", "My Parse App Id");    httpWebRequest.Headers.Add("X-Parse-REST-API-KEY", "My Rest API Key");    httpWebRequest.Method = "POST";    StreamWriter requestWriter = new StreamWriter(httpWebRequest.GetRequestStream());    requestWriter.Write(postString);    requestWriter.Close();    var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))    {        var responseText = streamReader.ReadToEnd();        JObject jObjRes = JObject.Parse(responseText);        if (Convert.ToString(jObjRes).IndexOf("true") != -1)        { isPushMessageSend = true;        }    }    return isPushMessageSend;}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5051557.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存