Search code examples
android.netpushandroid-c2dm

How do I create or get a password for sending notifications to C2DM?


I just signed up for C2DM, and got the following email:

Thank you for your interest in Android Cloud to Device Messaging (C2DM). We've accepted your application into the trial group. The Google account you requested as the sender account for your application: some.fake@email.com has been added to our list of allowed senders, and you should be able to start using it to send messages to Android 2.2 devices within the next day or so. If at any point you'd like to change the role account used for sending messages, please fill out the sign-up form again. By default, all new sender accounts are granted an initial production-level quota as documented in: http://code.google.com/android/c2dm/quotas.html If you need a higher quota, please follow the instructions on that page to submit a quota request. Note that since Android Cloud to Device Messaging is currently an API in Labs, we reserve the right to fundamentally change the service and associated quotas at any time. For more information on Android Cloud to Device Messaging, you can read our documentation and sample code at: http://code.google.com/android/c2dm/ If you have questions or feedback, please visit the Google Group at: http://groups.google.com/group/android-c2dm Please don't reply to this email, since the sender address is unmonitored. Thanks, Android Cloud to Device Messaging Team

So now I'm ready start pushing some notifications to C2DM. I have a .net based server side implementation using DroidPimp:

public class C2DMNotificationService : INotificationService<IAndroidPushNotification, C2DMChannel, IAndroidPhoneEndpoint>
{
    public void SendNotification(IAndroidPushNotification notification, C2DMChannel channel, IAndroidPhoneEndpoint endpoint)
    {
        var pusher = new Pusher();
        if (string.IsNullOrEmpty(notification.AuthToken))
        {
            // Note: this authtoken is refreshed periodically, so we need to think about how often we grab a new authtoken from google.
            var source = string.Format("{0}-{1}-{2}", channel.CompanyName, channel.ApplicationName, channel.Version);
            var loginResp = pusher.ClientLogin(channel.AccountEmailAddress, channel.AccountPassword, source);
            if (loginResp.StatusCode != ClientLoginStatusCode.Ok)
                throw new Exception("Got a bad login status: " + loginResp.StatusCode);
            notification.AuthToken = loginResp.AuthToken;
        }
        var sendMessageResp = pusher.SendMessage(endpoint.RegistrationId, notification.CollapseKey, notification.Values, notification.AuthToken, notification.DelayWhileIdle);
        // TODO: check response status..
    }
}

As you can see the pusher.ClientLogin method takes a password, but I don't have a password. I have a sender account, the one I used to sign up with C2DM, but I don't have a password. Where is the password or how can I get one?


Solution

  • As Paul said you need to register for the C2DM service with a valid email account that is controlled by Google. It doesnt have to be a gmail account but it needs to use the google email server (i.e. using you@yourdomain.com) if it's registered through google for email service.

    Once you have that you sign up for the C2DM service https://developers.google.com/android/c2dm/signup using that account,