当发送推送通知消息时,我正在
问题" MismatchSenderId"
我创建新项目并生成没有任何引荐来源的浏览器密钥。在发件人ID中,我使用"Project Number: 70171220582"
并在注册ID中使用了设备ID和生成的Application Id Used 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() +
"®istration_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();
}
答案 0 :(得分:0)
检查您的密钥是否有服务器应用。它应该如下所示。
参考:http://forum.shephertz.com/?qa=2754/push-notification-android-errorcode-mismatchsenderid