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.
  }
7270 questions
78
votes
3 answers

Handling registration ID changes in Google Cloud Messaging on Android

In the docs on Google Cloud Messaging, it states: The Android application should store this ID for later use (for instance, to check on onCreate() if it is already registered). Note that Google may periodically refresh the registration ID, so…
AndroidDev
  • 20,063
  • 26
  • 131
  • 216
77
votes
11 answers

Why do I get "MismatchSenderId" from GCM server side?

I'm trying to create a push service for my Android app, and I follow Google GCM's documentation and example for this matter: I can register/unregister my Android app. From my server side, I can see that I have one subscription registered, but when I…
Seyed Vahid Hashemi
  • 5,022
  • 9
  • 50
  • 86
74
votes
9 answers

Android Push Notification (GCM), is there any Daily Limit?

Is there any daily limit for number push notifications (GCM) can be sent to a particular android application user?
Sajith Amma
  • 1,049
  • 1
  • 9
  • 13
72
votes
2 answers

com.google.android.gsf package couldn't be found

I am trying to use new Google Cloud Messaging system but I have some problems. I read Getting Started document and reviewed demo app; after that I applied requirements to my application then I created a new virtual device with API 16. But when I try…
bahadir arslan
  • 4,141
  • 6
  • 38
  • 78
71
votes
4 answers

How To Create Topic in FCM Notifications

I'm trying Firebase-Notification API the service is worked perfect when i send downstream message from console to app, but how to send message to topic registered users ? i did in android side…
68
votes
9 answers

AWS SDK for PHP: Error retrieving credentials from the instance profile metadata server

I am trying to send SNS messeges to android through web api. Downloaded and installed the SDK from http://aws.amazon.com/developers/getting-started/php/ Got following error while running sample.php: Fatal error: Uncaught exception…
67
votes
5 answers

Is Firebase Cloud Messaging free?

I need to implement push notification feature in my application. Exploring some options. Google recently recommends Firebase platform, but this is not completely a free service. So I thought of using GCM again. Will google stop support for GCM in…
67
votes
21 answers

Firebase cloud messaging notification not received by device

I am having an issue with FireBase Cloud Messaging in which I get the Token from the device and send the notification test through the Google Firebase notification console however, the notification is never logged nor pushed to the android virtual…
xec86
  • 1,006
  • 1
  • 10
  • 16
63
votes
5 answers

Is GCM (now FCM) free for any limit?

I would like to know if Firebase Cloud Messaging is free or not for unlimited users?
62
votes
9 answers

Load image from url in notification Android

In my android application, i want to set Notification icons dynamically which will be loaded from URL. For that, i have used setLargeIcon property of NotificationBuilder in receiver.I reffered many link and tried various solutions but couldn't get…
59
votes
1 answer

Push Notifications or Socket.io?, or Both?

I'm developing a chat system for web, Android and iOS. Doing my research I've found differences on how GCM and APNS handle the Push Notifications. If I send a Push Notification to a Android Device through the GCM, the device its able to decide if it…
59
votes
4 answers

java.lang.RuntimeException: WakeLock under-locked C2DM_LIB

I have uploaded my application on google play but users have reported the following exception java.lang.RuntimeException: WakeLock under-locked C2DM_LIB. This exception occurs when I try to release the WakeLock. Can anyone tell what could be the…
Rookie
  • 8,182
  • 15
  • 55
  • 89
58
votes
1 answer

Push notifications (GCM) permission at runtime?

I have read that it is necessary to ask the user for some permissions at runtime for API 23 and up. For example: android.permission.ACCESS_FINE_LOCATION. Is it necessary (or even possible) to ask for a runtime permission for using GCM/push…
58
votes
5 answers

Getting an API key to use with Google Cloud Messaging

I am developing an Android app and I'd like to start testing out push notifications. From a code perspective, I'm all set. My current challenge is that I simply do not know how to get a Google Cloud Messaging API key from Google. There are loads…
Dave Ostrander
  • 615
  • 1
  • 5
  • 6
55
votes
6 answers

Weird push message received on app start

I'm getting a weird push message captured by my push service: Bundle[{CMD=RST_FULL, from=google.com/iid, android.support.content.wakelockid=1}] Just started to happen yesterday and I can't really spot which code change is to blame for this. Has…
vkislicins
  • 3,181
  • 3
  • 29
  • 54