【问题标题】:When send push notification getting error of "mismatch sender id"发送推送通知时出现“发件人 ID 不匹配”错误
【发布时间】:2015-04-24 05:11:22
【问题描述】:

当发送推送通知消息时,我收到了

问题“MismatchSenderId”

我创建新项目并生成没有任何推荐人的浏览器密钥。在发件人 ID 中,我使用了"Project Number: 70171220582",在注册 ID 中使用了设备 ID,在应用程序 ID 中使用了生成的 API 密钥。我也收到了回复,但在流阅读器中我收到了"Error=MisMatch SenderId" 消息。

我的代码在这里:

public void SendNotification(string data, HttpPostedFileBase CategoryCoverImage)
         {

             string RegId = "APA91bEvbPScQpHIwbIrOU5QPzFEEt6F7Ezrs5Cb7pG7pQBsEzuiv77S85F8WF6F2otHS8n8DXyuJrs-MQSpFMyx-07WOnMZKvzM3TkQZUdMQF";
             string ApplicationID = "AIzaSyBEXjdogpXXXXXXXXjvpOopU320";
             string SENDER_ID = "70171220582";
             var value = "Lokesh"; //message text box

             WebRequest tRequest;
       tRequest = WebRequest.Create("https://android.googleapis.com/gcm/send");
       tRequest.Method = "post";
             tRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";
             tRequest.Headers.Add(string.Format("Authorization: key={0}", ApplicationID)); tRequest.Headers.Add(string.Format("Sender: id={0}", SENDER_ID));
             //Data post to the Server
             string postData =
         "collapse_key=score_update&time_to_live=108&delay_while_idle=1&data.message="
          + value + "&file=" + CategoryCoverImage + "&data.time=" + System.DateTime.Now.ToString() +
          "&registration_id=" + RegId + "";

             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();  //Get response from GCM server  
             //label_Result.Text = sResponseFromServer; //Assigning GCM response to Label text
             tReader.Close(); dataStream.Close();
             tResponse.Close();
    }

【问题讨论】:

    标签: c# asp.net-mvc-4 push-notification google-cloud-messaging


    【解决方案1】:

    检查服务器应用程序的密钥。它应该如下所示。

    参考:http://forum.shephertz.com/?qa=2754/push-notification-android-errorcode-mismatchsenderid

    【讨论】:

    • 希望对您有所帮助!
    • 你的图片没有显示..但是我从两个(服务器和浏览器)获得了 api 密钥,我尝试了不同的项目,但我得到了同样的错误。
    • 没有。不允许IP。我检查了有 IP 或没有 IP,但得到了同样的错误。
    • 然后尝试允许任何 IP。根据我的回答
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-08-30
    • 2017-02-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-23
    • 1970-01-01
    相关资源
    最近更新 更多