Search code examples
androidandroid-c2dm

how to register an app to C2DM


Possible Duplicate:
Register the Android App with C2DM

so, I've been looking all over and reading everything I can put my hands on to check how to use C2DM with my super-cool chat app.

I saw that there was all sorts of stuff that my server guy has to take care of but I hadn't understood one thing.

The registration process has to include a senderId, that is basically a Google ID that is being transfered to the Google server as the app (or user) that is using the app, this identifies you as a push client.

My question is, do I have to prompt the user with a registration dialog? it seems like a horrible thing to do to my users since the app already uses Facebook connect and prompting too much of those are hostile for the users and will for sure make them uninstall the app.

what is the process of one app, registering for C2DM? and how can I use the already existing authentication token that the Google Play uses?


I read (for the third time) Vogella's turoial on using C2DM and this is the basis of my question:

public void register(View view) {
    Intent intent = new Intent("com.google.android.c2dm.intent.REGISTER");
    intent.putExtra("app",PendingIntent.getBroadcast(this, 0, new Intent(), 0));
    intent.putExtra("sender", "youruser@gmail.com");  //WHICH EMAIL?
    startService(intent);
}

is the Email used in the 4th line the device owner's email or the service email?

If we're talking about the user, is there a way of acquiring this without another authentication dialog? I already have a Facebook login and I don't want to cause the user discomfort.


Solution

  • please see the article of vogella , very brief implement guide for C2DM.

    http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html

    All the things mention over there as well as code, I personally implement its code and that is working fine.