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
1 answer

PeriodicTask and OneoffTask after migration from GCM to FCM

Question What should I use in place of PeriodicTask and OneOffTask when migrating from GCM to FCM? Is there any equivalent in FCM packages? Background Recently Google has deprecated GCM and they provided migration guide, but I couldn't find any…
2
votes
4 answers

Can you set thread-id with FCM notifications for ios

Firebase FCM messages support tag for Android which causes a new notification to replace the previous one with the older one with the same tag. Is there any way to do the same for ios? This answer suggest using thread-id in the data payload. But it…
2
votes
0 answers

How to get new token when migrate from GCM to FCM for existing app

I have application with GCM it's working fine,now i want to migrate from GCM to FCM. I have used this document for migration,everything working fine for new installed apk.It call the onTokenRefresh and i have used that token for future use. Issue…
MJM
  • 5,119
  • 5
  • 27
  • 53
2
votes
0 answers

Gcm RegistrationIntentService doesnot work on Android version 8 oreo

public class RegistrationIntentService extends JobIntentService { private static final String TAG = "RegIntentService"; private static final String[] TOPICS = {"global"}; private static Context context1; private String SENDER_ID; private…
Shubham Goel
  • 1,962
  • 17
  • 25
2
votes
1 answer

Argument cannot be null exception in google cloud messenger

We are using google cloud messenger for push notification. It was working fine few days before but suddenly it has started giving an exception. Following is the stack trace java.lang.IllegalArgumentException: argument cannot be null at …
Pawan Patil
  • 1,067
  • 5
  • 20
  • 46
2
votes
1 answer

How not to send FCM to users who don't want to receive push?

With GCM, when user expresses their preference whether they are willing to get notifications, we could mark their preference as active or inactive How can I achieve similar effect with FCM? When user says they don't want to receive pushes, we'd…
2
votes
0 answers

One signal push notification did not receive on device,while the application is in closed and device is locked

One signal push notification is not receiving in xiaomi Redmi 4,When the application is in closed state and also when the phone is locked.Is there have any method to receive push notification in all time when phone is locked,application is closed…
2
votes
1 answer

Batch push notification on Batch.onStart(this)

I use batch.com for push notification service, and i got error when initializing it. this my activity class: public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { …
Mohammad Ranjbar Z
  • 1,487
  • 1
  • 10
  • 20
2
votes
1 answer

Firebase message not received

I initialize Web firebase and I get Token: https://github.com/MarcinMoskala/KotlinAcademyApp/blob/master/web/src/main/web/js/initFirebase.js I get current token after it is created and I send it in simple message: curl -X POST -H "Authorization:…
2
votes
2 answers

Reliable Push Notifications with Android

I am relatively new to Android programming and invested a lot of time in reading and testing all about Services and Push-Notifications. I have the requirement for my App to deliver reliable (in terms of delivery time under one minute) Notifications…
2
votes
0 answers

android.app.RemoteServiceException with high crash rate in android vitals

I have been observing the following issue on my android vitals page but have no idea what is this related to or what am I missing in my app that is causing this. After doing a bunch of investigations I found this is related to stale resource ids…
2
votes
0 answers

How to ensure Google Maps works after migrating to Firebase?

I recently imported a GCM project into Firebase. I have downloaded the JSON file and the app is working, however when I launch the map it fails on authorization with the error "Ensure that the "Google Maps Android API v2" is enabled. Ensure that the…
Solly
  • 798
  • 3
  • 7
2
votes
2 answers

Can't pass aps parameter in body request of payload FCM?

click here to check postman request While migrating GCM to FCM I was using aps parameter in request body of GCM request body but when trying same for FCM its showing InvalidParameters. Url: https://fcm.googleapis.com/fcm/send Request: { …
2
votes
1 answer

Difference between GCM and Baidu Push Notification

I need to use Baidu Push notification in my app. But it is very difficult to find the documentaion on it to know about the difference from GCM. Is there any document or site available to know the exact difference between GCM and Baidu…
Ravi Kumar
  • 339
  • 2
  • 11
  • 24
2
votes
0 answers

Firebase notifications are not working for google play app

This is really wierd issue I have!! My app with firebase notifications. I am testing it between two phones: xperia e4g(api 19) and xperia z3(api 23) Notifications work when( notification received on target device) Sent through fb panel: both api19…
1 2 3
99
100