Google Cloud messaging - Server Example

I need a sample app for Google Cloud Messaging. with an example server for testing my application. can anyone help me with this?

I need a sample server to check my code, I already wrote the code, but I don’t know how it will work or not. I don't know server-side coding so anyone can help me with this. here is my code

earning service

package com.example.pushnotificationsample; import android.content.Context; public class GCMIntentService extends GCMBaseIntentService { protected GCMIntentService(String senderId) { super(senderId); // TODO Auto-generated constructor stub } @Override protected void onError(Context arg0, String arg1) { // TODO Auto-generated method stub } @Override protected void onMessage(Context arg0, Intent msgIntent) { // TODO Auto-generated method stub Log.d("GCM", "RECIEVED A MESSAGE"); // String msg=msgIntent.getStringExtra("Message"); Log.d("GCM", msgIntent.toString()); // Get the data from intent and send to notificaion bar } @Override protected void onRegistered(Context arg0, String arg1) { // TODO Auto-generated method stub } @Override protected void onUnregistered(Context arg0, String arg1) { // TODO Auto-generated method stub } } 

my main activity

 package com.example.pushnotificationsample; import android.app.Activity; import com.google.android.gcm.GCMRegistrar; import android.os.Bundle; import android.util.Log; public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); GCMRegistrar.checkDevice(this); // GCMRegistrar.checkManifest(this); final String regId = GCMRegistrar.getRegistrationId(this); if (regId.equals("")) { GCMRegistrar.register(this, "555817657362"); Log.v("Msg", "registered"); } else { Log.v("Msg", "Already registered"); } } } 
+11
android google-cloud-messaging android-c2dm
Jul 13 2018-12-12T00:
source share
4 answers

You need to download via the Android SDK. go to Window-> Android SDK Manager . Scroll to Advanced and check "Google Cloud Messaging" and install.

after completion, you can check: android-sdk/extras/google/gcm/samples

or you can try this (I downloaded it myself): gcm

for the server, check this answer: https://stackoverflow.com/a/31847/

+23
Sep 15 '12 at 12:53 on
source share
Command line tool

"curl" can be used to send messages to devices registered in GCM.

 curl -X POST \ -H "Authorization: key= <YOUR_AUTHORIZATION_KEY>" \ -H "Content-Type: application/json" \ -d '{ "registration_ids": [ "<YOUR_DEVICE_TOKEN>" ], "data": { "message": "<YOUR_MESSAGE>" } }' \ https://android.googleapis.com/gcm/send 

Please refer to this blog post for more information. http://www.zinniakhan.com/2014/07/check-google-cloud-messaging-gcm-client.html

+6
Jul 22 '14 at 1:22
source share

We have an example client on GitHub: https://github.com/indigorose/airbop-client (based on the sample GCM client) that works with our AirBop service based on GCM: http://www.airbop.com , with which you can test for free.

+5
Nov 30 '12 at 16:26
source share

I found an open source sender client for windows here: https://gcm.codeplex.com/

  • The device marker can be found after you enter the GCM registration code and get your registration ID through your client application (set a breakpoint or print instruction so that you can copy / paste this value, it takes quite a while)
  • An authentication key was found after setting up your project on the Google Developer Console.

screenshot

+4
Apr 03 '14 at 21:19
source share



All Articles