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
27
votes
6 answers

GCM defaultSenderID

Could somebody please help me understand what the gcm_defaultSenderId is in the following code (found in onHandleIntent in RegistrationIntentService.java): InstanceID instanceID = InstanceID.getInstance(this); String token =…
Brandon
  • 1,886
  • 2
  • 17
  • 28
27
votes
2 answers

Android Notification- Display full message

My Android Application has to be able to send short alerts out to a large group of people. The obvious place to do this is in the notification center. The full notification shows up in the ticker without a problem, but in the notification center a…
centree
  • 2,399
  • 7
  • 28
  • 32
27
votes
12 answers

How to fix INSTALL_PARSE_FAILED_MANIFEST_MALFORMED in my android application

Hi I am trying to experiment with gcm but unable to make it work. Don't know where I am messing with it, below is the error I am getting. I am trying to deploy my application directly on device and debug from there but when ever I try to deploy it…
Shax
  • 4,207
  • 10
  • 46
  • 62
27
votes
11 answers

When sending messages using GCM, I keep getting the response 'MismatchSenderId'

I'm implementing a push notification server with GCM. I send a post request with a sender ID (application key) that I got from Google API Console, and a registration ID that I got from the GCM service. The posted JSON includes one registration ID. I…
gilp
  • 571
  • 2
  • 6
  • 19
26
votes
3 answers

What is the `Authorization` part of the http post request of Google's Firebase Downstream message?

I want to try to send a message using google's FCM messaging service and as the document says, the http request should be something like this:…
26
votes
8 answers

java.io.IOException: SERVICE_NOT_AVAILABLE in GCM Client

I want to implement an gcm client into an existing android app. So, by following this tutorial I wrote following code: public class RegisterForGCMAsyncTask extends AbstractSecureOperationTask { ... @Override protected Boolean…
25
votes
2 answers

FCM HTTP V1 API returns 404 for unregistered token

FCM HTTP v1 API supposed to return error code "UNREGISTERED" when device is unregistered (app uninstalled). However API returns 404 "Requested entity was not found". Have anyone experienced this? Is this the expected one? There is no mention about…
yottabrain
  • 2,387
  • 5
  • 23
  • 37
25
votes
3 answers

Firebase Cloud Messaging API Key

Any way to regenerate the API Key for FCM (Cloud Messaging section) in Firebase Console? The key is not editable and is different from the one automatically generated in Google APIs Console. Due to this misconfiguration I'm always getting…
Jumpa
  • 4,319
  • 11
  • 52
  • 100
25
votes
1 answer

What's the difference between firebase cloud messaging & firebase notifications?

in the new Firebase 3.0, i am trying to get my head around when to use Firebase Cloud messaging and when to use Firebase Notifications.
jasan
  • 11,475
  • 22
  • 57
  • 97
25
votes
5 answers

Android Google Cloud Messaging (GCM) token generation crash after Firebase-related Google Play Services update

My Android application started crashing today when generating a token for Google Cloud Messaging (GCM). This happens on multiple devices and version of Android. I think it may have to do with the new Firebase features announced by Google yesterday…
Stephen
  • 1,373
  • 1
  • 12
  • 13
25
votes
5 answers

Making GCM work for iOS device in the background

I'm trying to use GCM for IOS and Android clients. It seems to work fine with IOS when app is in the foreground, however, when the app is in the background, the notification center doesn't receive the message and didReceiveRemoteNotification with…
25
votes
4 answers

Google Cloud Messaging in Delphi XE5?

I've got an android app that I am thinking about porting to Delphi but I can't see a way to interface with GCM. I am thinking I would possibly have to run the GCMBaseIntentService in java and interface with the delphi shared object? Alternatively, I…
FerretDriver
  • 381
  • 4
  • 11
24
votes
2 answers

Push notifications: Why use Amazon SNS over Google's GCM/FCM?

I have created a mobile app for Android and iOS using Phonegap Build. Last year I had nearly finished writing code to use GCM (Google Cloud Messaging) for remote push notifications - which can go out via Apple's APNS too - but the project was…
24
votes
4 answers

GCM unregister causing the application to crash

I've implemented GCM notifications on my app. I am now trying to un-register the app when the user logs out. I am using the following code. When this code executes, it causes the application to crash with the following…
Zeeshan Ali
  • 2,211
  • 4
  • 18
  • 25
24
votes
1 answer

Which port and protocol does Google Cloud Messaging (GCM) use?

Which port and protocol does Google Cloud Messaging (GCM) use? We experience some times that messages doesnt get through, and have noticed that it depends on which network we sitting on.
Thomas Vervik
  • 4,325
  • 9
  • 36
  • 64