GCM 3.0 - Need clarification about upstream message to devices - android

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.

Related

Send push notifications via Topic to all devices

I'm new to push notifications and here's what I understood so far -
Client app will need to register with Google Cloud Connection Server (GCCS).
GCCS will return a registration ID back to the client.
Client will send the device id and registration ID to the app server.
App server will store device & registration in its database. This database could get huge depending on the number users.
The app server in my case comprises of a single HTML page, and a node.js script. Admin will get to the page, types in a message and hits Send.
The app server will make a POST call to GCCS with the Sender ID, API Token, array of registration ID's etc.
Message is received by the devices.
There is also this thing called as Topics that the client apps can subscribe to. Using Topics, you do not have to send registration ID's of all devices. All devices "subscribed" to this Topic will get the message. This is very useful if you have millions of users (depending on the popularity of the app) and you don't have to split the registration ID's into chunks of 1000s to send the message.
My questions are -
If we're using Topics, do we need to persist the Registration ID, Device ID to a database on the App server? It seems redundant.
Are there any ready-to-use/commercial GCM servers that can send Topic messages?
Is it easy enough to build on your own (since its a simple POST call)? If I'm going to use JavaScript, wouldn't I run into CORS issue?
Thanks for the help!
If we're using Topics, do we need to persist the Registration ID, Device ID to a database on the App server? It seems redundant.
Are you referring to C2DM implementations? Those are deprecated as shown on the GCM documentation. In relation to topics, they may not be necessary but are necessary to other message calls.
Based on the documentation, to needs to be set as topic/[yourTopic] with the necessary payload
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!",
}
}
Are there any ready-to-use/commercial GCM servers that can send Topic messages?
I can't find any sources about this, so I'm guessing we're left to implement it on our own application server. Google provided us with a sandbox project for us to play with.
Is it easy enough to build on your own (since its a simple POST call)? If I'm going to use JavaScript, wouldn't I run into CORS issue?
If you're talking about setting up the Client App (specifically Android), there's a setup guide on the documentation. But if its more on the application server, I can't comment on it really. XMPP libraries can be used to handle XMPP Connection Servers

GCM Sent messages before subscribing

I just implemented Google Cloud Messaging successfully in my Android application and to test it I sent some messages from my server, that worked perfectly.
I was wondering what happens if I send a message to an specific topic and then a device subscribes to that topic, will it receive the message?
Will my users receive the messages I sent while I was testing it?
Thanks
I have not found this behavior defined in the GCM documentation. My experience (version 8.3.0) has been that when a client subscribes to a topic, it does not receive messages previously sent to that topic. Although messages have a default time_to_live of 4 weeks, server processing to hold the message and send it later is only applied to devices that have subscribed but are not able to receive the message because they are turned off or do not have a network connection.

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

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

UnExpected reply from GCM Server when i am sending the Expected URL

**Question (i)**
I have registered my android app in my mobile (Samsung Galaxy Pop) i am recieved a
registrataion_id
APA91bG9NI4U2jr4sUn1HLy5nHMFe1e0JOTgOoZv1Px**********************************
when i sent this registration_id to server side code which is refrenced from here
here i used function SendNotification having 2 parameters
My Registration_ID
My Message Which i want to show on notufication
http://www.codeproject.com/Tips/434338/Android-GCM-Push-Notification
I hit the GCM- Server and the result I got is
id=0:1368258967353783%978fee9266d6cf16
I did not understand what does this response means ? is it good ? bad ?
Question (ii)
if mobile device gets registration id from gcm server is it registered or still waiting for server side to send the Registration ID to GCM Server
Please help !! , Thanks in advance
Answer to(i)
The data you are getting is on plain text format and the data is refering to the message id. In this case the message was correctly sended.
To understand how it works visit this page GCM Architectural Overview
Answer to (ii)
The way GCM works it's
Your device request a registretion to GCM services.
Device is registered correctly by receiving the regId.
You send that regId to your server to receive push notifications.
Server saves the data
Servers wants to send a message to that device, sends a mesage using GCM services.
The device, if it is online, receives it and knows wich app haves to start.
The app receives the message.
On the same website you have further explanation, by the way start reading from getting started section.

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

Categories

Resources