I am trying to send an upstream message from device to cloud using the new Cloud Connection Server feature of Google Cloud Messaging. I am using the example code in Getting Started guide.
http://developer.android.com/google/gcm/gs.html
I am able to set up the client side and am getting the registration ID. But when I send the
message to the server nothing happens. I am not sure if I need to do some setup at the server end.My basic server requirement is to receive the message from the client and send a response back. I am using a Java based backend server.I could not find anything concrete in the documentation regarding server side set up.
Can anyone please help ?
Yes this is definitely possible
http://developer.android.com/google/gcm/ccs.html
The GCM Cloud Connection Server (CCS) allows third party servers to communicate with
Android devices by establishing a persistent TCP connection with Google servers using the
XMPP protocol. This communication is asynchronous and bidirectional.
You can't just register to GCM at the client side and send messages to your server. That only takes care of the connection between your device and the GCM server.
You have to set up your server's connection to the GCM Cloud Connection Server (CCS) in order to be able to send and receive messages at your server :
GCM Cloud Connection Server (CCS) is an XMPP endpoint, running on
http://gcm.googleapis.com port 5235.
CCS requires a Transport Layer Security (TLS) connection. That means
the XMPP client must initiate a TLS connection. For example in smack,
you would call setSocketFactory(SSLSocketFactory), similar to “old
style SSL” XMPP connections and https.
CCS requires a SASL PLAIN authentication mechanism using
#gcm.googleapis.com (GCM sender ID) and the API
key as the password, where the sender ID and API key are the same as
described in Getting Started.
You can use most XMPP libraries to interact with CCS.
GCS is currently in beta and requires you to apply for it. Quoting the documentation page:
Note: To try out this feature, sign up using this form.
Did you sign up? After that Google should get back to you and give you access to the service.
Related
I have my own app server which communicate with FCM server. And I have Android/iOS mobile apps working well.
I want to set a third party program using Java which send a message to FCM server repeatedly so I can keep tracking my own app server is working fine.
I tried to find a solution but official website mention about upstream message only with Android/iOS app.
Is it possible to send a upstream message to FCM server using Java?
(Or any other good idea to monitor the server? I faced the server sometimes goes down for some reason without notice it :( )
There is currently no way to send upstream messaging other than what is shown in the docs -- currently available for Android and iOS.
Even if you are able to send an upstream message, it wouldn't make sense. The flow of upstream messaging is:
Client App > FCM Server > App Server
So the result/response that you would get when sending a message, should it succeed/fail, will point out the communication between the FCM server and the Client App, not with the App Server.
I'm writing an Android chat application right now using Openfire as the xmpp server. The problem is that if I use the Xmpp server for push notification, it is fine for when user is online but it has some issues when user is offline. So is there a way to configure Openfire to let GCM to host the push notification? Is the re such thing as a GCM plugin for Openfire?
We have build an application with almost similar conditions like yours. However, for sending push to offline users we send it through server side.
In your implementation while sending message you can check if the user is offline then you can hit your server api to send push. (Also you can implement the GCM on client side too only you have to know its deviceToken or the GCM id)
XMPP manages the offline messages. So you need to handle only the pushnotification part and need not worry about saving the message.
My android app uses GCM to send or receive text messages. At first, when a user install my app, it uses the GCM api to get a GCM_id from Google. After getting this long GCM id, app sends this id to my web server to say that this client is registered with that id.
My question is that about this step. Since firstly app gets the GCM id and sends it to my web server, I think, someone can listen the requests of the app and sends dummy GCM_ids for this client (or any other clients if guess my client id format). How can I secure this step to prevent unwanted interrupts and attacks.
While creating gcm_id, if google would send this id to my server also before sending it to client, it would be a solution to my problem. But google sends it to client only directly.
ps: Using ssl is not a solution I think. Because it can also be opened by programs like fiddler .
This document (https://developer.android.com/google/gcm/http.html) describes the Google Cloud Messaging (GCM) HTTP connection server. Connection servers are the Google-provided servers that take messages from the 3rd-party application server and sending them to the device.
Consider i prepared a HTTP server for GCM based on this document. how i can send information to GCM with PHP? should i use POST method? how? or it doesn't related to PHP?
Yes, you should send a POST request to https://android.googleapis.com/gcm/send. It doesn't matter which language you are using in your server. PHP would work just fine.
I have created an IM app that uses asmack to connect to various xmpp protocols such as google talk and facebook.
Occasionally some messages are lost in transit (both sent and received messages) when switching between Wifi/Data or when you lose signal altogether. Is there any way to retrieve the last received messages for that particular protocol when the app manages to reconnect? I find myself having to constantly check the default messaging app to see if any messages came through while I was disconnected.
Also, how about a way to get obtain delivery confirmation upon sending a message?
Thanks!
If you use a server that supports XEP-0136: Message Archiving or XEP-0313: Message Archive Management, you'll be able to obtain all messages previously sent.
However, neither Google Talk nor Facebook Chat implements these, and afaik they have no alternative XMPP API for it either.