Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:44:16+00:00 2026-05-31T17:44:16+00:00

I’m trying to create an application that uses c2dm service. So. First I used

  • 0

I’m trying to create an application that uses c2dm service.

So. First I used google email/password get an authentication key from the c2dm server for the application.

The android app, registers with c2dm server with a different email to get a registration-id and sends the id over to me (to the application)

I use my authentication-key and the registration-id of the device to send a c2dm. So the authentication-key and registration-id were generated using two different emails.

When I send the c2dm, I receive this error: Got error response from Google datamessaging endpoint: MismatchSenderId

Following is my code:

public class C2DMTest 
{
    public static void main(String... args) throws Exception 
    {
        //authentcation using email1
        String auth = "DQAAALoAAADu5rxXlYkYecVYIYKywIkvhhb70SMXgniYqeCNt15i70aO6wmuPBrAYZMMort0z1InHsjblB_R9sLR0wa6mD1CEM9IZH_POhC9iGLKsBO9EBremJJzTCzmj9EVCCWv3-SxYAOJ1CCKVNE7x9oHAehTSapBYWwk80ZjQ19rC2Q8BRctF3aPDLbZBbjyq6rQjUbEQU1vA_WTbgwyENSmNOT_GtTaEUCYtmKauRoOW6TV-LxTWTsvzUApCclSqovcXlk";
        sendMessage(auth);
    }

    /**
     * Send message to mobile device.
     */
    @SuppressWarnings("deprecation")
    public static void sendMessage(String cl) throws IOException 
    {

        String key = "APA91bGgIm0_yjPvr_Wao20XRMJP2HhQSjY2FL9O56CwL73UHqPg_TUrux_voUy3pi_k1aKt1MUt0SkpKCANpC_iw1LQ0szkW9Bs-TFv5lBNyvZZgCBW3H9oIbpQLkz0bUspIY4KqHjaDnaIqSelQLbEbolLQPwHscIQDRIul_W9YVNUTiOhDr8";

        StringBuilder postDataBuilder = new StringBuilder();
        postDataBuilder.append("registration_id").append("=").append(key);
        postDataBuilder.append("&").append("collapse_key").append("=").append("0");
        postDataBuilder.append("&").append("data.payload").append("=").append(URLEncoder.encode("test-content", UTF8));
        byte[] postData = postDataBuilder.toString().getBytes(UTF8);

        URL url = new URL("https://android.apis.google.com/c2dm/send");

        HostnameVerifier hVerifier = new HostnameVerifier() {
            public boolean verify(String hostname, SSLSession
                    session) {
                return true;
            }
        };

        HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
        conn.setHostnameVerifier(hVerifier);


        conn.setDoOutput(true);
        conn.setUseCaches(false);
        conn.setRequestMethod("POST");
        conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
        conn.setRequestProperty("Content-Length", Integer.toString(postData.length));
        conn.setRequestProperty("Authorization", "GoogleLogin auth="+cl);

        //------------------
        OutputStream out = conn.getOutputStream();
        //--------------------------
        out.write(postData);
        out.close();

        int sw = conn.getResponseCode();
        System.out.println("" + sw);
        switch (sw) 
        {
            case 200:
                System.out.println("Success, but check for errors in the body");
                break;
            case 503:
                System.out.println("Service unavailable");
                break;
            case 401:
                System.out.println(" Invalid authentication token");
                break;
        }


        String responseLine = new BufferedReader(new InputStreamReader(conn.getInputStream())).readLine();
        String[] responseParts = responseLine.split("=", 2);

        if (responseParts[0].equals("id")) 
        {
            System.out.println("Successfully sent data message to device: "+ responseLine);
        }

        if (responseParts[0].equals("Error")) 
        {
            String err = responseParts[1];
            System.out.println("Got error response from Google datamessaging endpoint: "+ err);
            throw new IOException(err);
        }




    }
}

Please let me know why I’m getting this error message. Thanks so much in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:44:18+00:00Added an answer on May 31, 2026 at 5:44 pm

    Make sure you use the same e-mail for sender intent extra field and on the server. So your server authentication value must come from the same e-mail that you use as sender on the client side.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create an if statement in PHP that prevents a single post
Basically, what I'm trying to create is a page of div tags, each has
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.