Google Cloud Messaging (GCM) and uploading data from an Android phone - android

Simple question: is it possible to tell an Android phone to take a photo and send it (provided I have an appropriate client app installed), and all of that using only GCM? Or is there a size limit on the messages pushed from the phone?

The GCM documentation doesn't say explicitelly what's the size limit for an upstream message (device to cloud), so it's safe to assume the same size limit applies for both upstream and downstream messages - i.e. 4k bytes.
Unlike a send-to-sync message, every "message with payload" (non-collapsible message) is delivered. The payload the message contains can be up to 4kb.
Therefore you can't use GCM to send a photo from your phone to your server. You could send a downstream message from your server to the app via GCM, and the broadcast receiver that handles that message can start an intent service that would take the photo, contact your server and upload to it the photo (not using GCM).

As Eran said, its quite true. Please follow Google GCM Services:
http://developer.android.com/google/gcm/index.html
And other related documentation can be found at:
http://developer.android.com/google/gcm/gcm.html

Related

How to send a simple Firebase push notification to everyone from the client?

I've been doing so much research, but it seems like all the articles out there are either sending notifications from the console or sending a push notification to a single device.
All I want is to send a push notification using Firebase ON my client and not on the Console to everyone. Do I need a server? If so, what information do I need to retrieve from it?
If you simply want to send a downstream message, you don't really need a server. You can simply use Postman or cURL. Just specify the registration token(s)/topic you want to send your message payload to.
If you are aiming to send the downstream message from the client (Android app) itself, I would strongly advise not to. Quoting a portion of #FrankvanPuffelen's answer here:
Sending a message to devices (so-called downstream messages) requires a HTTP call that specifies the server key. As its name implies, this key should only be used in environments you can trust.
It is to avoid exposing the key to unauthorized users, preventing exploitation.

GCM 3.0 - Need clarification about upstream message to devices

I'm currently trying to understand how works the new Google Cloud Messaging and some things remain a bit blurry for me.
From what I understood, a downstream message is a message sent by the app server through GCM cloud. It can be sent to a specific sender, device group or topic suscribers.
An upstream message is a message sent by a sender to the app server through the GCM CCS. In this case, it looks like something like that :
gcm.send(SENDER_ID + "#gcm.googleapis.com", messageId, data);
On the official website (here), it says we can use upstream messages with devices :
gcm.send(notificationkey, messageId, data);
I don't understand well how it works in that case. A message is sent to GCM CCS (upstream) then that one automatically delivers it to the given device group/senders (thus downstream (XMPP message response ?) ?) ?
I'm a bit confused, any clarification would be appreciated.
notification_keys are used to perform Device Group Messaging, which is a message sent to multiple devices.
Before you can send messages to a device group, you must create a device group, which returns a notification_key and register devices in it.
Once devices are registered, an upstream message sent to CCS with the to field set to the notification_key, GCM will relay the message to all devices registered in the device group with the corresponding notification_key.
This allows the sender to send one message to many devices instead of many messages to many devices.
Hope this helps clear things up.

Can I depend on GCM service to create a big instant messaging application ?

If I want to create an instant messaging application using android, is it a good and efficient to use the Google Cloud Messaging API ?
There are a lot of mentions in GCM documentation and tutorial saying that is no guarantee of order and success receive of messages. Like here:
Note that since there is no guarantee of the order in which messages
get sent, the "last" message may not actually be the last message sent
by the application server.
I suggest you use this as a call to update user chat e.g. when your app get a GCM you request your server-side to get the new messages but not transfer messages by GCM itself also because you have some dayly limits as well.
See more here: http://developer.android.com/google/gcm/index.html
I found the mention above here: http://developer.android.com/google/gcm/server.html. At description of collapse_key here: http://developer.android.com/google/gcm/server.html#params
Yes, it works for Google and you won't have to maintain servers. If your message is short, in can be included in the GCM message. Otherwise the GCM could be a payload to notify your app to check for a new message.

GCM Message Delivery Confirmation

I am implementing push notifications with Google Cloud Messaging. I am simply testing with their demo applicaitons on official site.
All is working well.
But, has anyone idea of how to gurantee the delivery of message, in anyway?
Or can we invoke server to let know once the message are delivered in device, and will it be reliable approach?
Take a look at the answer on Android GCM delivery monitoring.
"They don't guarantee delivery but they try for a max of 4 weeks to deliver the message depending on the duration you set in the message you send to Google's GCM servers and if you wish to let Google keep the data for eventual delivery of msg to the device in case the device was offline when the message was to be delivered."
Google has added support so that you can receive delivery receipts from Cloud Connection Server (CCS):
You can use upstream messaging to get delivery receipts (sent from CCS to your 3rd party app server) when a device confirms that it received a message sent by CCS.
To enable this feature, the message your 3rd-party app server sends to CCS must include a field called "delivery_receipt_requested". When this field is set to true, CCS sends a delivery receipt when a device confirms that it received a particular message.
https://developers.google.com/cloud-messaging/ccs#receipts

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 Google servers once we received a new message. The issue is that testing process has reported about serious problems with push notification delivery to devices.
So the question: is there an approaches for monitoring average statistics about push notification delivery percentage, time etc? Or maybe somebody have experience in how to set up test environment for efficient monitoring of how much notifications are getting lost during the application work?
All the "tips&tricks" related to the improving Android GCM experience are welcome.
Google claims that the processing at their GCM server takes less than a millisecond. Link below for a great video on GCM from Google's developer. And it's believable coz I could get push notifications almost instantaneously using my company's server to my device now.
http://www.youtube.com/watch?v=YoaP6hcDctM
They don't guarantee delivery, but they try for a max of 4 weeks to deliver the message depending on the duration you set in the message you send to Google's GCM servers and if you wish to let Google keep the data for eventual delivery of message to the device in case the device was offline when the message was to be delivered.
However, there are certain conditions under which the GCM messages are not delivered.
Background data is unchecked under Account and Sync settings.
Prior to 4.0.4.(ICS), a Google account on the device is a pre-requisite for GCM. Maybe, Users are not logged into their Google account.
The only way to do so is to report back to your server with the timestamp of the received push.
You can either
Report back to the server once you receive the notification in your GCM service. To implement, you will have to add a push id for your push notifications and send the id along with the push data. The client will have to get the timestamp once it receive the message and send it back along with the notification id. A simple php script can be done (when you send a push notification, you set the time of the send-notification and once it receives the device's timestamp it sets the receive-notification. This boils down to two fields in your database (marked in bold). In this approach you will probably not so much care about errors since it is very probable that the device will have a connection when it receives the notification and as such its request to your server will go through.
Keep a list of notifications received in your app and their timestamps. And when the sync is done, send the this data in your sync operation. This is ultimately the same approach but your server's data won't be as realtime as the first approach. However, the extra request is not required from the client's side but saving the received notifications and their timestamps is.
All in all, you will have to keep track of the notifications sent using a notification-id and their sending time (send-notification) and their receive time (receive-notification). A simple query will help you analyze this data.
Google has added support so that you can receive delivery receipts from Cloud Connection Server (CCS):
You can use upstream messaging to get delivery receipts (sent from CCS to your 3rd party app server) when a device confirms that it received a message sent by CCS.
To enable this feature, the message your 3rd-party app server sends to CCS must include a field called "delivery_receipt_requested". When this field is set to true, CCS sends a delivery receipt when a device confirms that it received a particular message.
https://developer.android.com/google/gcm/ccs.html#receipts
Google does not make these statistics available to you. There are some statistics available on the android developer console. This only shows the number of messages and registrations.
You would have to implement your own data collection, which could be done fairly easily. You could record the time & id of each message sent and have your android client report back to your server with the time of message receipt. You could then store the data on your server and query as needed.
Since that time Google has provided developers with advanced monitoring tool.
The Gcm Diagnostic Tool is available in Google Play developer console. Additional information is here https://support.google.com/googleplay/android-developer/answer/2663268
So you can easily track the particular message status via registration token.

Categories

Resources