Questions tagged [google-cloud-messaging]

Google Cloud Messaging is a service to allow data to be sent remotely to Android and iOS applications and Chrome extensions and packaged apps.

Firebase Cloud Messaging (FCM) is the new version of GCM. It inherits the reliable and scalable GCM infrastructure, plus new features! See the FAQ to learn more. If you are integrating messaging in a new app, start with FCM. GCM users are strongly recommended to upgrade to FCM, in order to benefit from new FCM features today and in the future. See the FCM tag.

Google Cloud Messaging (GCM) is a free service that enables developers to send messages between servers and client apps. This includes downstream messages from servers to client apps, and upstream messages from client apps to servers. The GCM service handles all aspects of queueing of messages and delivery to client applications running on target devices, and it is completely free.

The service provides a simple, lightweight mechanism that servers can use to tell mobile applications to contact the server directly, to fetch updated application or user data. The service handles all aspects of enqueuing of messages and delivery to the target application running on the target device.

The free service has the ability to send a lightweight message informing the Android application of new data to be fetched from the server. Larger messages can be sent with up to 4 KB of payload data. Each notification message size is limited to 1024 bytes, and Google limits the number of messages a sender sends in aggregate, and the number of messages a sender sends to a specific device.

For example, a lightweight downstream message could inform a client app that there is new data to be fetched from the server, as in the case of a "new email" notification. For use cases such as instant messaging, a GCM message can transfer up to 4kb of payload to the client app. The GCM service handles all aspects of queueing of messages and delivery to and from the target client app.

Send messages from the cloud

Send a message using GCM HTTP connection server protocol:

  https://gcm-http.googleapis.com/gcm/send
  Content-Type:application/json
  Authorization:key=AIzaSyZ-1u...0GBYzPu7Udno5aA
  {
    "to": "/topics/foo-bar",
    "data": {
      "message": "This is a GCM Topic Message!",
     }
  }

Handle a downstream message on an Android device:

  @Override
  public void onMessageReceived(String from, Bundle data) {
     String message = data.getString("message");
     Log.d(TAG, "From: " + from);
     Log.d(TAG, "Message: " + message);
     // Handle received message here.
  }
7283 questions
3
votes
2 answers

Not receiving message from GCM server

I am working on a project that notifies an android application using push notifications using Google Cloud Messaging. I have implemented the application server in PHP. When i run the android application, the device gets the registration id from the…
jigargm
  • 155
  • 3
  • 15
3
votes
1 answer

How restrict a particular device in Google Cloud Messaging Service?

I am playing around with the Google Cloud Messaging sample code given in Android SDK. Both the client and server code works fine. I have installed the GCM client android app in three android devices and when the server is running each of the devices…
Vishnu Rajan
  • 241
  • 3
  • 9
3
votes
1 answer

GCM server side code in android

I tried the code for GCM given here Using this I am able to get the registration id for my application (I checked on the device and found it got printed onto the TextView that I set). But now how can I check for the receiving of messages (push…
Sharath G
  • 91
  • 2
  • 6
3
votes
2 answers

Android - GCM for development, do I need a physical device?

If I want to use GCM in a development environment, can I use the Android mobile device emulator or do I need a physical device? I want to run the GCM Demo Application.
dmotta
  • 1,843
  • 2
  • 21
  • 32
3
votes
3 answers

Code gets stuck at wakelock,while registering to GCM?

It does not get registration id from GCM server the app does not give any error,this is my logcat. 07-13 16:43:39.920: I/** pushAndroidActivity **(5310): inside oncreate() 07-13 16:43:39.920: I/** pushAndroidActivity **(5310): started…
Rishikesh
  • 117
  • 3
  • 11
3
votes
1 answer

cannot use GCMRegistrar?

cannot use the GCMRegisterar from gcm.jar which i have added to build path ,but still i am getting this message in logcat. 07-12 14:29:08.825: I/dalvikvm(23536): Could not find method com.google.android.gcm.GCMRegistrar.getRegistrationId, referenced…
Rishikesh
  • 117
  • 3
  • 11
3
votes
5 answers

App registration ID not generating in GCM Android

I have tried some forum pages and searched through stackoverflow for the same thing, but I did not find the solution. I have used the below code to generate registration ID for GCM notification. But I get an empty string as a registration…
3
votes
1 answer

Creating war file in Windows 7

I am trying to set up a GCM Demo Application. http://developer.android.com/guide/google/gcm/demo.html I am stuck trying to create a war file: In a shell window, go to the gcm-demo-server directory. Generate the server's WAR file by running ant…
user182192
  • 729
  • 3
  • 14
  • 26
3
votes
2 answers

app isn't woken up on receiving gcm message broadcast

I've recently added GCM messaging to my app using google's helper classes (GCMBroadcastReceiver, GCMBaseIntentService). It works beautifully when the app is running, both when it's in the foreground and when it's not. However, when it's not…
jph
  • 2,181
  • 3
  • 30
  • 55
3
votes
2 answers

GCMBroadcastReceiver lacks WAKE_LOCK permission that is declared in manifest

I've implemented GCM as closely to Google's examples as I can, but the default GCMBroadcastReceiver is throwing a SecurityException for lack of the WAKE_LOCK permission. I require it in the my manifest, though, so AFAIK it should have that…
3
votes
2 answers

Is there a Wordpress Plugin for Google Cloud Messaging (GCM)

I'm looking for a plugin for the Wordpress environment for Google Cloud Messaging. Is one available or would it be difficult to create?
gimpy
  • 1,129
  • 2
  • 13
  • 27
3
votes
2 answers

GCM android, Push Notifications not being recieved

I am working on an android app that will recieve push notifications from the GCM server. I am using php as the 3rd-party server. I've a few questions. When I send request to gcm server from my php script it gives me the following response …
Mj1992
  • 3,404
  • 13
  • 63
  • 102
3
votes
1 answer

How to specify the device to which we want to send messages

I was reading the Google Developers documentation, and I was not able to find how to let GCM (Google Cloud Messaging) know to which device we want to send the message. I am working on an application in which I'll be saving users' email addresses in…
Mj1992
  • 3,404
  • 13
  • 63
  • 102
2
votes
1 answer

Android Cloud to Device Messaging without google account

Is it true that if a user does not have Cloud to Device Messaging (C2DM) in his account the C2DM will not work? If so, how can I do push notifications without a Google account?
user2514963
  • 156
  • 3
  • 19
2
votes
0 answers

How to upload APNs key, team id, key id on firebase through cloud console service account json using google cloud php client library?

I am currently using the Cloud Console to manage some of my services, and I perform all activities through the APIs provided by the console. I am using a Cloud Console service account JSON for authentication. Additionally, I am using the Google PHP…