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
2
votes
0 answers

Firebase Cloud Messaging Error in Android app

I'm trying to integrate FCM in my android app to enable it to receive push notifications from server. As reference, I followed all the steps in this page: https://firebase.google.com/docs/cloud-messaging/android/client to configure my client android…
2
votes
1 answer

Urban Airship Android GCM not receiving push notifications on Android Oreo and Pie

Just updated the app to API 27 and added com.urbanairship.android:urbanairship-gcm:9.1.0 to build.gradle file. I can receive push notifications on Android N and below but doesn't work when triying on Android O and above, I already assigned a channel…
2
votes
2 answers

About GCM implementation Android application after April 11, 2019(GCM is abolished)

I would like to migrate a GCM Client App for Android to Firebase Cloud Messaging. In the Firebase console, I selected my GCM project from the list of existing Google Cloud projects, and add Firebase, and now, even if I update my server code to use…
2
votes
1 answer

Can we receive gmail push notifications for multiple users to same push end point using cloud pub/sub

I have implemented code in java for receiving gmail push notifications. It is working perfectly fine for the mail id, in which I have created the project, topic and subscription. The notifications are published to my mentioned URL and I can fetch…
2
votes
0 answers

Firebase Messaging getToken() do nothing / Chrome Extension Background

I am developing a chrome extension. I want to send FCM messages to extension via Firebase from external server by specific token, but I can't receive this token. I try to receive token in background script by call the following code: async function…
2
votes
0 answers

GCM not working on 8.0 and 9.0 devices but still working on earlier version

My QA team found that our push notifications to GCM aren't working on devices running 8.0 and 9.0 but still seem to working on the 5.x and 6.x test devices no problem. The response from the GCM server seems fine for all pushes being sent out and I…
draksia
  • 2,371
  • 2
  • 20
  • 25
2
votes
1 answer

Link existing Firebase and Google Cloud projects

I am trying to migrate my Android app from GCM to FCM. I use Google Cloud project for GCM and Firebase project for some Firebase features (Analytics, etc.) now. Docs say that I need to import Google Cloud project to Firebase, but I already have…
2
votes
1 answer

GCM push notification issue in android P (28)

we're using GCM for push notification for our app with target release to 26. Using class GCMJobIntentService extends JobIntentService for push notification services because of target release 26. It's now android P released and push notification…
Pankaj
  • 833
  • 12
  • 35
2
votes
1 answer

com.google.android.c2dm.intent.RECEIVE android 9 (sdk 28) doesn't work

I'm having issues with the new Android-SDK 28 from Google. (Android Pie) I'm trying to send a c2dm cloud message (push notification), everything works fine on API level lower or equal to 27 (tested with real phones and simulator), but on API level…
2
votes
1 answer

Android GCM - WakefulBroadcastReceiver.startWakefulService crash due to IllegalStateException 8.0

We just migrated app's target api to Android API 27 (8.1) and it keeps on crashing when notification arrives specially when the app is in the background. java.lang.RuntimeException: Unable to start receiver .service.GCMBroadcastReceiver:…
2
votes
1 answer

GOOGLE FCM (Cloud Messaging) Notifications Not Showing up on Mobile Device

I have created a mobile application with Push Notification. The App grabs the Token from Google FCM stores it into a database. Then we use a dashboard to send a notification to all registered devices. There has been an issue with our notifications.…
2
votes
1 answer

Crash on GcmIntentService on Android 8 (Oreo)

I have implemented GcmIntentService for push notification everything was working fine but when updated version to Android 8 (Oreo) it is getting crash on oreo devices. Is it possible that I can continue uses of GcmIntentService for push…
2
votes
1 answer

firebase set background message handler

I have been trying to customise notification message in front end, i.e if a field is not set send in notification, I am trying to add…
2
votes
0 answers

Android Oreo GCM push notification icon white, when app is closed

I've read the ~10 similar questions to this on SO, and some other google search, and documentation pages, and I still can't figure out what the issue is. Basically, if the app is closed (or backgrounded), the push notification icon shows up as a…
2
votes
1 answer

GCM Network Manager is deprecated. Firebase Jobdispatcher is not working persistently in background?

I heard that GCM get's deprecated on April 11, 2019. I have implemented GCM Network manager in my project, I am running service persistently in the background, though internet connectivity on or off. Firebase job dispatcher is not running like GCM…