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
24
votes
5 answers

Android GCM delivery monitoring

I am developing mobile client for emailing service. One of the key features is notifications about new messages in the mailbox. As recommended by GCM architecture guidelines we are using a "Pusher" that is responsible for sending messages to the…
rus1f1kat0R
  • 1,645
  • 1
  • 16
  • 22
24
votes
3 answers

How to get RegistrationID using GCM in android

I am trying to do push notification in android using GCM. I read the Google docs for GCM and their demo application. I created the client side program mentioned here http://android.amolgupta.in/. But i am not getting registration ID. Also I am not…
Neha
  • 414
  • 1
  • 4
  • 14
23
votes
2 answers

Messaging: The notification permission was not granted and blocked instead

Firebase messaging error in https server. An error occurred while retrieving token. FirebaseError: Messaging: The notification permission was not granted and blocked instead. (messaging/permission-blocked). What should I do to get my token? On…
23
votes
4 answers

Android 23+ - Exclude GCM Registration ID from backup

I have an app which uses Azure to send Push notifications. Azure in turn, uses GCM to send to Android devices. I'm noticing that I have a warning in my AndroidManifest.xml stating On SDK version 23 and up, your app data will be automatically…
23
votes
5 answers

Chat App for Android using a XMPP Server and Google Cloud Messaging (or the newer Firebase Cloud Messaging) for Push Notifications

I'm developing a Chat App for Android. I have been reading for weeks about XMPP and Google Cloud Messaging (and Firebase Cloud Messaging) and I am still very confused. Currently, I already setup an XMPP server locally (Ejabberd) and successfully…
23
votes
6 answers

Android notification is not showing it's content when app is not running

Here is my interesting problem. Android notification that comes from GCM is not showing title and content (just shows App Name, and when click, open the MainActivity) when app is not running. But when the app is open, it's showing successfully…
Ozgur
  • 3,738
  • 17
  • 34
23
votes
1 answer

how can we get device token for android for push notification?

i want to implement push notification in my application.i want to know,how we get the device token for push notification in android after enabling the google cloud messaging API.How can we get a device token for a particular device??
23
votes
2 answers

google-services.json location in the project tree

I am following this manual and I am unsure where I should exactly copy the file google-services.json? There's many folders containing an app folder and I am trying to develop this for android wear. Any guide would be really great. So far I have put…
Mona Jalal
  • 34,860
  • 64
  • 239
  • 408
23
votes
4 answers

How to generate valid APNS Certificate (.p12) for use in GCM for iOS?

I am trying Google Cloud Messaging sample app for iOS platform. https://developers.google.com/cloud-messaging/ios/start To generate GoogleServices-Info.plist APNS development and production certificates are needed (PKCS#12 file format). I have…
23
votes
6 answers

Google Cloud Messaging - GCM - SERVICE_NOT_AVAILABLE

I am trying, to implement the new GCM, I am following Google get stated : http://developer.android.com/guide/google/gcm/gs.html I getting stuck at getting my device registration ID ! My app keep trying to connect with Google server, Here my error…
22
votes
4 answers

How to send FCM (firebase cloud messaging) push notification from ADB to device

We are using firebase cloud messaging to get the push notification into android app. Currently to test push notification we need to send the message to FCM server and wait for the message to arrive to device. Most of the time device is taking long…
22
votes
2 answers

Azure Notification Hub no longer accepting GCM API Key

Recently, every time I try to add or modify the GCM API Key in an Azure Notification Hub, I get the following error: SubCode=40000. Failed to validate credentials with GCM. The remote server returned an error: (401) Unauthorized... I have tried…
22
votes
4 answers

Failed to resolve: com.google.android.gms:play-services-measurement:9.0.2

I didn't find out what's causing the problem below. Could you help me, please? Error:Failed to resolve: com.google.android.gms:play-services-measurement:9.0.2 Install Repository and sync projectOpen FileShow in Project Structure dialog
Marcel
  • 421
  • 2
  • 8
  • 18
22
votes
2 answers

push silent notification through GCM to Android/IOS

I'm seeking to send an state update to an application, which can (or not), be silent. For example, if the user gets a new message from one of their friends I want to send such message and be able to display an alert with sound. But in the silent…
Onza
  • 1,710
  • 4
  • 18
  • 31
22
votes
6 answers

'The 'Pods' target has transitive dependencies that include static binaries' when installing GCM

I'm trying to install Google Cloud Messaging for my iOS application (using swift). I've added it to my Podfile like so: # Uncomment this line to define a global platform for your project # platform :ios, '8.2' use_frameworks! target 'Project' do …
Dan
  • 569
  • 2
  • 4
  • 15