Question

I am trying to use google cloud messaging service to store gcm id when user login into the system but i do not how to do it on login activity.Anybody can help me with any working sample?

Was it helpful?

Solution

May be you can follow this link or most prefered from android developers. Here's another link with nice tutorial about implementing google Cloud messaging

OTHER TIPS

please use below function:

public static String registerClient(Activity activity) {
        String regId = "";
        String registrationStatus;
        try {
            // Check that the device supports GCM (should be in a try / catch)
            GCMRegistrar.checkDevice(activity);

            // Check the manifest to be sure this app has all the required
            // permissions.
            GCMRegistrar.checkManifest(activity);

            // Get the existing registration id, if it exists.
            regId = GCMRegistrar.getRegistrationId(activity);

            if (regId.equals("")) {

                registrationStatus = "Registering...";

                // register this device for this project
                GCMRegistrar.register(QwichesApplication.mContext,
                        CommonVariable.GCM_PROJECTID);
                regId = GCMRegistrar.getRegistrationId(activity);

                registrationStatus = "Registration Acquired";
                Log.d("tag", regId);
                // This is actually a dummy function. At this point, one
                // would send the registration id, and other identifying
                // information to your server, which should save the id
                // for use when broadcasting messages.

            } else {

                registrationStatus = "Already registered";

            }

        } catch (Exception e) {

            e.printStackTrace();
            registrationStatus = e.getMessage();

        }

        Log.d("tag", regId);

        // This is part of our CHEAT. For this demo, you'll need to
        // capture this registration id so it can be used in our demo web
        // service.

        return regId;

    }

this function returns gcm_id . i hope its useful to you...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top