如何使用asp.net使用PARSE REST API发送通知? [英] how to send a notification using PARSE REST API using asp.net ?
本文介绍了如何使用asp.net使用PARSE REST API发送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请分享从asp.net向Android应用程序发送通知的源代码。或者请分享一步一步的过程。非常感谢..
我尝试使用以下代码,但它没有发送通知。如果我错了,请纠正我。
Please share the source code for sending notifications from asp.net to android applications. Or else please share the step by step process. Thanks Much..
I tried with the below code but it is not sending the notification. Please correct me if I am wrong.
bool isPushMessageSend = false;
string pushMessage = "Test Push from .Net";
string postString = "";
string urlpath = "https://api.parse.com/1/push";
var httpWebRequest = (HttpWebRequest)WebRequest.Create(urlpath);
postString = "{ \"channels\": [ \"\" ], " + "\"deviceType\": \"android\", " + "\"data\" : {\"alert\":\"" + pushMessage + "\"}" + "}";
httpWebRequest.ContentType = "application/json";
httpWebRequest.ContentLength = postString.Length;
httpWebRequest.Headers.Add("X-Parse-Application-Id", "MyAppID");
httpWebRequest.Headers.Add("X-Parse-REST-API-KEY", "MyAppRESTkey");
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;
}
}
推荐答案
Hello Balakrishnan,
请查看推送通知教程 [^ ]可在PARSE网站上找到。他们还有教程的源代码。
问候,
Hello Balakrishnan,
Please have a look at the Push Notification Tutorial[^] available on the PARSE website. They also have the source code for the tutorial.
Regards,
这篇关于如何使用asp.net使用PARSE REST API发送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文