1

When sending message (using Java) to GCM server I get the the exception:

[ errorCode=MismatchSenderId ]

Here I checked my apikey and senderid. Both are in same project. please help to fix this issue.

I am using windows system and programming with java for sending message to GoogleCloudMessaging. As per documentation of GCM, I am sending regid (which will sent by andridd device) and apikey and some textmessage. Here regid and apikey are used same google account. Using this details I sent message to GCM server. It says :mismatchsenderid... Please guide me..

public static void main(String[] args) {
    Sender sender = new Sender("AIzaSyBXXXXXX");
    Message message = new Message.Builder()
        .collapseKey("1")
        .timeToLive(3)
        .delayWhileIdle(true)
        .addData("message", "this").build();
    Result result;
    try {
        result = sender.send(message,"APA91bFYa3SNWhUOywguYHN1XXXXXXX", 1);
        System.out.println(result.toString();
        /* Message message1 = new Message.Builder() .build();*/
    } catch (Exception e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
    }
} 
Eran
  • 387,369
  • 54
  • 702
  • 768
Hemanth
  • 21
  • 1
  • 5
  • 1
    If you want to get help here, you'll need to better describe your problem and the environment and you'll need to show us your code. – Codo Jan 01 '13 at 13:20
  • sorry i cann't able to paste my code here because i maintain 4 to 5 files.but i can describe the problem .am using windows system and programming with java for sending message to GoogleCloudMessaging.As per documentation of gcm i am sending regid(which will sent by andriod device)and apikey and some textmessage . Here regid and apikey are used same google account.using this details i sent message to GCM server it says :mismatchsenderid...please guide me..and please check below code which tells how am calling my code – Hemanth Jan 01 '13 at 13:49
  • public static void main(String[] args) { Sender sender = new Sender("AIzaSyBXXXXXX"); Message message = new Message.Builder() .collapseKey("1") .timeToLive(3) .delayWhileIdle(true) .addData("message", "this").build(); Result result; try { result = sender.send(message,"APA91bFYa3SNWhUOywguYHN1XXXXXXX", 1); System.out.println(result.toString(); /* Message message1 = new Message.Builder() .build();*/ } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); }} – Hemanth Jan 01 '13 at 13:51
  • I've added your comments to the question. The code is much easier to read that way. – Codo Jan 01 '13 at 15:46
  • Your question most likely is a duplicate of http://stackoverflow.com/questions/11307689/when-sending-messages-using-gcm-i-keep-getting-response-mismatchsenderid and http://stackoverflow.com/questions/11313342/why-do-i-get-mismatchsenderid-from-gcm-server-side – Codo Jan 01 '13 at 15:57
  • Hi, As you told i read that,my senderid and apikey also matched .Senderid is sending to GCM server to get registrationid here once andriod app successfully registered then gcm giving one registration id. In my server code(as above explained in code) am sending the registrationid and apikey.Here apikey and senderid using same google account....(am not using senderid in my server code) – Hemanth Jan 02 '13 at 06:20

2 Answers2

2

If your Sender ID and API Key match (and you are using the correct value for Sender ID, which is the Google API Project ID), the most likely explanation to your problem is that you are using an older Registration ID that was generated for a different Sender ID.

Eran
  • 387,369
  • 54
  • 702
  • 768
0

Please run below script in your terminal

curl -X POST \
-H "Authorization: key= write here api_key" \
-H "Content-Type: application/json" \
-d '{
"registration_ids": [ "write here reg_id generated by gcm"
], "data": { "message": "Manual push notification from Rajkumar" },
"priority": "high"
}' \
https://android.googleapis.com/gcm/send

MismatchSenderId because with in same device you have logged with different keys. to solve this problem uninstall app and run it againg and update the registration key. and then run the CURL script in your teminal which i post above it will give success message and you will get notification to your device

Raj Kumar
  • 688
  • 8
  • 18