Android Google Cloud Messaging (GCM) and missmatched sender id
android, google-cloud-messaging
Solution
I actually had the same problem, and was researching more than 10 hours.
I finally found out the problem! Nothing related to the Server API key or Browser API Key or SenderID. The problem was the Google documentation:
final String regId = GCMRegistrar.getRegistrationId(this);
if (regId.equals("")) {
GCMRegistrar.register(this, SENDER_ID);
} else {
Log.v(TAG, "Already registered");
}
Google says that you have to call the getRegistrationId function and only if the id is empty call register! Which did not work for me at all... when I did that I always got back MismatchSenderId when sending to this regId.
My solution was: Always call
GCMRegistrar.register(this, SENDER_ID);
and when the function
protected void onRegistered( Context c, String regId )
is called save the regId in my server database.
if I do it this way, all works fine!
Problem
I am trying to use the GCM service in my android app. For that, I used the android documentation from http://developer.android.com/guide/google/gcm/gcm.html I created the client side registration process with the sender id etc and the server side application where I am using the registration id and the sender id to send messages. When I am installing the app in my phone through Eclipse, the push notifications works fine, so the sender id i have is right. Then, when i export the apk file with Eclipse and install it in my phone, I am getting the error message that the SenderId is wrong ``` MissmatchedSenderId ``` Anyone has an idea whyI am getting this. I have read those topics: Why do I get "MismatchSenderId" from GCM server side? When sending messages using GCM, I keep getting the response 'MismatchSenderId' But the strange thing in my case is that everything works fine before exporting the app as apk and then I have this problem. Any idea is mostly wellcome.