响应成功但FCM通知未在设备上收到

时间:2017-12-11 05:53:35

标签: c# firebase-cloud-messaging

{
 "multicast_id":5269694491339255869,
 "success":1,
 "failure":0,
 "canonical_ids":0,
 "results":[{
             "message_id":"0:1512971008200317%c522639e66d6cf16"
           }]
}

var applicationID =" AAAAIzHIwq4:xxxxxxxxxxxxx&#34 ;; // applicationID表示谷歌Api密钥                         var SENDER_ID =" 1511xxxxxxxxxxxx&#34 ;; // SENDER_ID只是您的ProjectID(来自API控制台 - 谷歌代码)
                        var value = txtmessage.Text.Trim();

                    WebRequest tRequest;

                    tRequest = WebRequest.Create("https://fcm.googleapis.com/fcm/send");
                    tRequest.Method = "post";
                    tRequest.ContentType = " application/json";
                    tRequest.Headers.Add(string.Format("Authorization: key={0}", applicationID));
                    tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
                    string postData = "{\"collapse_key\":\"score_update\",\"time_to_live\":0,\"delay_while_idle\":false,\"data\": { \"message\" : " + "\"" + value + "\",\"registration_ids\":[\"" + Reg_Id + "\"]}";
                    Byte[] byteArray = Encoding.UTF8.GetBytes(postData);
                    tRequest.ContentLength = byteArray.Length;
                    Stream dataStream = tRequest.GetRequestStream();
                    dataStream.Write(byteArray, 0, byteArray.Length);
                    dataStream.Close();
                    WebResponse tResponse = tRequest.GetResponse();
                    dataStream = tResponse.GetResponseStream();
                    StreamReader tReader = new StreamReader(dataStream);
                    String sResponseFromServer = tReader.ReadToEnd();
                    tReader.Close();
                    dataStream.Close();
                    tResponse.Close();

以上是fcm服务器响应 但未在设备上收到通知。 应用程序处于空闲状态。 从c#代码发送通知

0 个答案:

没有答案