0

I am using C2DM for "Push Notification" on Android. Every thing is okay.

My question is; can I get "if device has more than synchronized gmail accounts, which one is used for C2DM"?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
sem
  • 61
  • 1
  • 9
  • it has no concern with if device has more than sync accounts – Shankar Agarwal Apr 21 '12 at 07:39
  • For example; x@gmail.com and y@gmail.com accounts synchronized with device. My app registered with x@gmail.com. And then user remove "the" account? – sem Apr 21 '12 at 07:50
  • removing account from device does nothing but on should not deactivate account from gmail i mean you should not delete your account – Shankar Agarwal Apr 21 '12 at 07:51
  • gmail account is used to send messages from server it not concerned with you device – Shankar Agarwal Apr 21 '12 at 07:52
  • 3 components; c2dm - gmail account - device. c2dm send messages to gmail account. isn't gmail account associate with device? Who is sending message to device? I can't figure out the process, if there is no relation between gmail account and device. (and thanks for your replies) – sem Apr 21 '12 at 08:07

1 Answers1

0

Refer this link for C2DM and sample at this LINK. Now you device think where it is related to device.

In the below code the email id use is not device specific. C2DM uses email id just for interaction between server and C2DM not depending on device.

// Call when your application start

public void StartRegistrationNotification()
    {

        Intent registrationIntent = new Intent("com.google.android.c2dm.intent.REGISTER");
        registrationIntent.putExtra("app", PendingIntent.getBroadcast(this, 0, new Intent(), 0));
        registrationIntent.putExtra("sender", "....@gmail.com");
        this.startService(registrationIntent);  

}
// change in Manifest File

<receiver android:name="com.ReceiverC2DM"
        android:permission="com.google.android.c2dm.permission.SEND">
        <!-- Receive the actual message -->
        <intent-filter>

            <action android:name="com.google.android.c2dm.intent.RECEIVE" />
            <category android:name="yourpackagename" />
        </intent-filter>
        <!-- Receive the registration id -->
        <intent-filter>
            <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
            <category android:name="yourpackagename" />
        </intent-filter>
    </receiver>
    <permission android:name="yourpackagename.permission.C2D_MESSAGE"
    android:protectionLevel="signature" />
<uses-permission android:name="yourpackagename.permission.C2D_MESSAGE" />
<!-- This app has permission to register and receive message -->
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64