Reputation: 21
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();
}
}
Upvotes: 1
Views: 3063
Reputation: 796
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
Upvotes: 0
Reputation: 393771
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.
Upvotes: 2