1

I was able to obtain the Registration key on my client app using the code

GCMRegistrar.register(this, "805421596082");

I received the Registration id.

I AM USING THE FOLLOWING JAVA CODE TO POST MESSAGE.

import java.util.ArrayList; 

import com.google.android.gcm.server.Message; 
import com.google.android.gcm.server.MulticastResult; 
import com.google.android.gcm.server.Result;
import com.google.android.gcm.server.Sender; 

public class Notify { 

    public static void main(String args[]) { 

        try { 

            Sender sender = new Sender("AIzaSyAj0cooI3YxBzbug-6CcmJQdRXxGKphRbU"); // This is the server api key 

            Message message = new Message.Builder() 
            .collapseKey("1") 
            .timeToLive(3) 
            .delayWhileIdle(true) 
            .addData("message", 
            "this text will be seen in notification bar!!") 
            .build(); 

            Result result = sender 
            .send(message, 
            "APA91bEMi5lmYKxaJX4-80eUp1JsW50_jSbZoqUs16xswI9EuXK_Km3qyuGxvoqKBvg9_5009naFrF7VKBknOKEo946SWtH57cd_m5BbTxpgaaT_Iy-m9McyV6aqy6BjxAy0d57arqp2yq6mHZrgw7qx-o4ntv7T2Q",  // This is the registration id
            1); 


        } catch (Exception e) { 
            e.printStackTrace(); 
        } 

    } 
}

WHEN I LOG THE RESULT VALUE I AM GETTING "[ errorCode=MismatchSenderId ]"

I am not able to proceed further. It would be great help if somebody could suggest me a solution for this.

vinod
  • 558
  • 5
  • 10

1 Answers1

4

API key and senderID should be belong to the same account. And also you should use the same registrationID that is generated using the given senderID. Check your keys.

It is explained in the GCM page as follows :

A registration ID is tied to a certain group of senders. When an application registers for GCM usage, it must specify which senders are allowed to send messages. Make sure you're using one of those when trying to send messages to the device. If you switch to a different sender, the existing registration IDs won't work. Happens when error code is MismatchSenderId.

Parvin Gasimzade
  • 25,180
  • 8
  • 56
  • 83