使用.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;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)