-3

I'm new with google cloud messaging, so I was looking for tutorials about this but I just found out old tutorials. I know GCM changed a bit, so Can anyone can recommend me a new tutorial using php to send push messages or something like that.

I found this question but I didnt find registerId in console developer GCM with PHP (Google Cloud Messaging)

Community
  • 1
  • 1
nanoalvarez
  • 83
  • 2
  • 4
  • 10
  • “Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, [describe the problem](http://meta.stackexchange.com/q/139399/) and what has been done so far to solve it.” [What topics can I ask about here?](http://stackoverflow.com/help/on-topic) – Anil Jan 24 '14 at 21:29

1 Answers1

0

Yes, the GCM has changed its console and documentation too. Here is the link for latest GCM tutorial using PHP server. http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

You cannot find registration Id in the console. There is only sender id (project number) in the console. Later in the program, when you register your application in GCM using your sender ID, only then you get registration Id.

There are lot of beginners who search the registration Id in the developer console. Let me clarify this When you register into the console, after creating a project, you will be provided with the project number enter image description here

You will use this as a SENDER ID in the program to get the registration ID. Here is the pseudo code for this.

registration_id = gcm.register(sender_id)

From the android application pass this registration_id to the application server (e.g. PHP).

URI url = null;
        try {
            url = new URI("http://YOUR_SERVER_URL/register.php?regId=" + registration_id);
        } catch (URISyntaxException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } 
        HttpClient httpclient = new DefaultHttpClient();
        HttpGet request = new HttpGet();
        request.setURI(url);
        try {
            httpclient.execute(request);
        } catch (ClientProtocolException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

In register.php file, retrieve the registration ID

regId = $_GET['regId'];

and save it into the database. When you want to send the message to the android application, you can simply use this registration id and send your message.