The best place to learn basic information is here at developer.android.com
You will see this sample code in your tutorial:
private void registerInBackground() { new AsyncTask() { @Override protected String doInBackground(Void... params) { String msg = ""; try { if (gcm == null) { gcm = GoogleCloudMessaging.getInstance(context); } regid = gcm.register(SENDER_ID); msg = "Device registered, registration ID=" + regid;
If I understand correctly, you are confused about how to get the GCM RegistrationId to implement your server. You can do this in the sendRegistrationIdToBackend() method, which you define.
You need to create an endpoint to receive a POST request so that each device sends its registration ID as soon as it receives it from GCM. Then your server implementation will know about all the devices on which your application is installed and registered in GCM.
NOTE. One thing you might want to keep an eye on is not creating duplicate login identifiers if the device finishes placing its login ID twice or the user uninstalls and then reinstalls the application, but GCM gives them the same login ID with which you can encounter duplicates stored in your database on the server. If this happens, and you want to send push to all your users, then some of your users may receive several push notifications, depending on the number of duplicates in the database.
source share