在Android App中使用C#进行FCM通知-WebException

时间:2019-05-21 05:44:26

标签: c# android server cordova-plugin-fcm

FCM通知在IIS托管的本地/用户系统中运行后端C#项目代码时成功接收。但是,当在客户端服务器上的IIS中托管托管部署的同一C#项目时,我们发现WebException无法在Android App中接收通知。

string postbody = Newtonsoft.Json.JsonConvert.SerializeObject(payload).ToString();
            Byte[] byteArray = Encoding.UTF8.GetBytes(postbody);
            tRequest.ContentLength = byteArray.Length;
            using (Stream dataStream = tRequest.GetRequestStream())
            {
                dataStream.Write(byteArray, 0, byteArray.Length);
                using (WebResponse tResponse = tRequest.GetResponse())
                {
                    *using (Stream dataStreamResponse = tResponse.GetResponseStream())
                    {
                        if (dataStreamResponse != null) using (StreamReader tReader = new StreamReader(dataStreamResponse))
                            {
                                result = tReader.ReadToEnd();
                                //String sResponseFromServer = tReader.ReadToEnd();
                                //result.Response = sResponseFromServer;
                            }
                    }
                }
            }
  

*在WebException下方使用(Stream dataStreamResponse = tResponse.GetResponseStream())

{https://fcm.googleapis.com/fcm/send}
true
false
true
MutualAuthRequested
None
{Level:BypassCache}
{System.Security.Cryptography.X509Certificates.X509CertificateCollection}
null
null
383
"application/json"
null
350

任何帮助/建议将不胜感激

0 个答案:

没有答案