1
votes

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();
    }
} 
2
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
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
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
I've added your comments to the question. The code is much easier to read that way. - Codo

2 Answers

2
votes

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.

0
votes

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