-2

I am developing android push notification application using C2DM,I am facing some problems in my application. The application is working when I am using same email address on both i-e server and client applications,

Can anyone tell me what will be the problem.

Altaf

Altaf
  • 5,150
  • 10
  • 39
  • 55
  • 1
    This is the first time I've seen somebody think that having their application work is a problem. Also, this is a duplicate of http://stackoverflow.com/q/6725570/778427. If you didn't get an answer the first time, it's likely that there's a problem with the way you're asking it. Don't go reposting your questions. – Glendon Trullinger Jul 18 '11 at 01:36

1 Answers1

1

It seems that you are under the wrong impression that the Role Email account which is created to identify the application using the C2DM service should be changed in the registration intent.

You must have that role email the same as the one on the server otherwise Google will not be able to identify your application as sender/receiver of this c2dm message. Sample Registration Intent:

    Intent registrationIntent = new Intent(
            C2DMessaging.REQUEST_REGISTRATION_INTENT);
    registrationIntent.setPackage(C2DMessaging.GSF_PACKAGE);
    registrationIntent.putExtra(
            C2DMessaging.EXTRA_APPLICATION_PENDING_INTENT,
            PendingIntent.getBroadcast(context, 0, new Intent(), 0));
    registrationIntent.putExtra(C2DMessaging.EXTRA_SENDER, senderId);
    context.startService(registrationIntent);

The Variable senderId here should hold the role account you created and signed up for C2DM on the google C2DM signup Page

This same email is used to obtain the Authentication token from google servers which is used to send C2DM messages later

Sample server code to get an authentication key:

        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(1);
        nameValuePairs.add(new BasicNameValuePair("Email",
                senderId));
        nameValuePairs.add(new BasicNameValuePair("Passwd", "testpassword"));
        nameValuePairs.add(new BasicNameValuePair("accountType", "GOOGLE"));
        nameValuePairs.add(new BasicNameValuePair("source",
                "Fleet Tracker Pro"));
        nameValuePairs.add(new BasicNameValuePair("service", "ac2dm"));
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        HttpResponse response = client.execute(post);
        BufferedReader rd = new BufferedReader(new InputStreamReader(
                response.getEntity().getContent()));

        String line = "";
        while ((line = rd.readLine()) != null) {
            if (line.startsWith("Auth=")) {
                String auth = line.substring(5);
                System.out.println("Auth token = " + auth);
                return auth;
            }
        }

notice the variable senderId this should also hold the role account you created and signed up for C2DM on the google C2DM signup Page any other email can be changed to whatever you like, but these to emails have to remain identical

here is the definition from google C2DM page at google code:

Sender ID An email account associated with the application's developer. The sender ID is used in the registration process to identify a Android application that is permitted to send messages to the device. This ID is typically role-based rather than being a personal account—- for example, my-app@gmail.com.

I hope i helped have a nice day.

would have been nice if you included code snippets or more information about the emails you are talking about.

Shereef Marzouk
  • 3,282
  • 7
  • 41
  • 64