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

Google Cloud Messaging dont return Canonical ID

I have deliberately registered my app several times to GCM to test the canonical id concept, but the cloud doesnt return it to me. See my server log below, its the same device and I can see in the Android log that it received the message four times.…
Thomas Vervik
  • 4,325
  • 9
  • 36
  • 64
3
votes
3 answers

Gcm phone_registration_error

I'm trying to set up an application to work with gcm but every time I get the phone_registration_error error according to the Gcm documentation this error means: Incorrect phone registration with Google. This phone doesn't currently support…
just_trying_stuff
  • 366
  • 1
  • 3
  • 12
3
votes
1 answer

How to play sound file when GCMIntentService onMessage fires?

In my application I am using GCM services. I want to beep or play a small mp3 file at onMessage function. My GCMIntentService is extended from GCMBaseIntentService. Can somebody please share the code or suggest me how to achieve this. Thanks
Shax
  • 4,207
  • 10
  • 46
  • 62
3
votes
0 answers

Get data from Android HTTP Post

There are two sides in my application; 1> gcmserver & 2> AppDevice and I'm using google's GCM in my application(both gcmserver & AppDevice) + using two different systems(one for gcmserver ,another for AppDevice). Now the issue is: To my server end…
user1645434
  • 193
  • 3
  • 13
3
votes
2 answers

Can gcm be used to send and receive messages between android devices?

I have two android devices that runs a gcm client app. I get the Reg IDs of both the devices. I also have a server API key. Now the thing is, Using a simple php code using cUrl or Zend framework, I'm able to send message from a web server to one of…
venkatKA
  • 2,399
  • 1
  • 18
  • 22
3
votes
1 answer

Show Dialog in GCM onMessage()

I am implementing GCM (Google Cloud Messaging) into my App. I set it up all like in the Google Tutorial, and it works so far. I display a notification in the notification-bar when onMessage when the GCMIntentService gets called. Now I have a method…
3
votes
3 answers

GCM Registration id create every time when app start?

My application start Registration id create every time and send to server. public class MariTimeGlobalNewsSplash extends Activity { /** Called when the activity is first created. */ public final static String AUTH = "authentication"; …
Android
  • 2,383
  • 1
  • 26
  • 44
3
votes
2 answers

How can an application server associate Google accounts to a user's device?

I want users to be able to enter data from a web server and/or native PC app and transfer it to their chosen Android device in much the same way that Google Play's install on device works. I'd like to use the user's Google account authentication to…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246
3
votes
0 answers

c2dm receives NotRegistered after gcm registration

I've run into a pretty bizarre problem with c2dm. Seeing as it's deprecated, I've begun the process of migrating to gcm. Due to the design of this product, I can't simply register for gcm and send the new registration id to my backend and forget…
hankystyles
  • 511
  • 2
  • 8
3
votes
1 answer

Push Notification to particular device in Android

I am creating an Android app where in I will require the push notifications. I can send notifications to multiple Devices very perfectly..There is no issue at all.. Here the query is How can I send Notification to particular device (or user). Like…
Riddhi Barbhaya
  • 1,205
  • 1
  • 11
  • 19
3
votes
1 answer

Two ways for registration and starting service in Google Cloud Messaging (GCM)

I'm trying to develop an application with GCM. I read the official document about GCM, but feeling like there are two ways for doing these. 1. As for registering an android device for GCM It seems like there are two ways for registering a device to…
Ryo
  • 2,003
  • 4
  • 27
  • 42
3
votes
1 answer

Google Cloud Messaging and less battery drain

I've heard that GCM provides less energy consumption.How does GCM provide higher battery life exactly? What is the difference with GCM? It is said that server sends a message to app when there is something to get.So app doesnt have to check the…
3
votes
2 answers

Bad Request sending gcm message

I am trying to send gcm message via C#. I tried several times, but I get http:400-Bad request while trying to send it in json method. When I try to send it in text, I can't read it (rtl language) - that's why I am trying JSON. Anyone knows what the…
Shkolar
  • 337
  • 7
  • 20
3
votes
2 answers

Google Cloud Message and Android version

I am planning to implement Google Cloud Messaging in in my app which only runs with Android 2.2 and above.This includes modifying the Manifest file. If my app is to run at Android 2.1, it immediately shows a force close dialog. May I know how do…
neobie
  • 2,847
  • 5
  • 27
  • 31
3
votes
1 answer

Received HttpResponse 400 from PHP server using Zend framework

I am trying to send push notifications to my android application using PHP server with Zend framework, but i am getting the HttpResponse as : The request could not be parsed as JSON or contains invalid fields, with the error code 400. I have used…
jigargm
  • 155
  • 3
  • 15