C2DM background technology - android

I need further information about C2DM on android. The informations on http://code.google.com/intl/de-DE/android/c2dm/index.html are not clear about the background technology.
Which protocolls are used?
How does the Google server find my cell phone?
I need such informations.

You can get some info about C2DM internals from Google I/O 2010 video: Building push applications for Android

C2DM maintains an open TCP socket connection to the messaging server. Its really rather simple, other than keeping the socket open, which is no exactly trivial.

Related

Device to device messaging using GCM without registering an app server

Is it possible for a device to send message to other devices using Google cloud messaging without an app server at all?
I have a centralized database using Google Cloud Datastore. The app will get required registration ids from the centralized database and the database is updated by all the devices. So, getting registration ids is not a problem.
Can this be done using upstream messaging? I am not sure because i have searched a lot but never saw an example where app server is not used for this purpose.
This question is not duplicate of another question, because here i have central database to store registration ids which is mentioned as a problem in another question.
In the most basic sense no, not at this time. You cannot send an upstream message from one device to another without an app server. You can create an app server on your device application but that is not recommended. The current recommendation would be to use an app server to facilitate your device to device messages.
To answer is it possible? Yes it is.
Sometime back I have created a POC to send GCM message to self, so I know its very much possible. I configured my GCM to work with any ip in developer console i.e. 0.0.0.0.
just use HTTP post to send your message from android as you would have done from Server.
Like (most) everything else, there is an API for that.
Google hosts its GCM service on GCM Connection Servers. The official document requires you to create an App Server to issue the API requests to the Connection Servers.
Alternatively you could setup the Connection Server to accept requests from any IP around the world, and then issue the requests via your client app. The API is here and it's quite simple.
Seurity issues
Bundling your API key with your app, and setting the Connection Server to unrestricted connections is an obvious major security issue.
Why bother?
Why bother doing all of this? Instead I would use a free service like Parse.com, which takes care of the users database and offers up to 1000000 messages a month free.
Has anyone actually done this. I would like to see example android project.

GCM Server/Sender Setup for Device-to-Device Communication in Android

I've been reading through the GCM developer page and none of it seems too complicated. However, from an overview standpoint, I'm confused on exactly what I want. I have an application on one device that will send some information to another Android device, which then does something with that information. It's just a pair of doubles.
I've never had any experience doing much web communication aside from simple website/router stuff, so I realize this is a very inexperienced question-- but when I set up GCM on my two devices, what device is acting as the "server" and which as the "client"? Are both clients and Google is the server?
Thanks for any help.
I think you Want to Make Two side communication. you can Do One think that Save your RegistrationID of phone on to the Server. what ever the Data you want to communicate you should save it First to server. and whenever the Notification sent by the Server it will give information to perticular Client with using Registration ID.
Both android devices are considered clients. The clients will communicate with a backend server which can be implemented in a variety of ways. The sample that Google provides uses a standard web app written for the Java App Engine. You can find the example here:
Setting Up the Server
You can also write the server using ASP.NET, PHP, etc. What I typically will have on the backend is also a SQL database to manage the devices that are registered with my application. Each device (client) is given a unique ID from Google which the server will use to communicate. The server uses this ID because the messages it will send is not directly to the client but to GCM service. So in essence the Google GCM is a server to your backend server which is a client to GCM.
Hopefully this answers your questions regarding client/server communication. Please look at Googles demo for detailed implementation. Good luck!

Persistent connection between GWT and Android client (or App Engine inbetween)

What I'm trying to achieve is a connection between a users browser (logged in with his Google account) and an Android application on his phone (also logged in with the same Google account). I want to send a bunch of text formatted as JSON from GWT to the device and the other way round too.
My first thought was to send a C2DM ping to the Android devices and wake up a service witch connects to the App Engine server or the GWT client directly (if that's possible).
What I'm doing now is a socket with the Channel API from GWT to App Engine. And for a large amount of text I would just send a notification via the Channel to the GWT client, which then gets the data with a RPCall. Missing is the connection between the App Engine and the Android application. What I could do is C2DM for one direction and simple HTTP requests for the other direction. I don't like this solution, because C2DM can be really slow some times. Is there a solution to connect these two (GAE & Android app), or even a better without App Engine and a connection between the GWT client and the Android client directly ?
Thanks in advance :)
If I understand your question correctly, you're looking to push messages from a server (in your case GAE) to an Android app without using C2DM? In that case you can give pubnub a try.
Edit: of course you have a few options in this area (another one being Urban Airship) but you'll notice that they're not cheap!
I'm not sure what you mean by "a connection between GWT and Android directly" -- do you mean a connection between a GWT client and an Android phone? If so, there's not a good way to do that without installing client software; you'll need some sort of server to proxy messages.
So, given that you're using App Engine and GWT already, and C2DM is potentially too slow, you could wrap up an HTML page on the Android and use the Channel API. Then when you get messages, have your javascript client (again, running on Android) call the container to do anything you want.
This is nice because you have parity in the message delivery between your browser clients and your Android clients. It's not nice because it's not native and probably will eat battery, unlike C2DM.
Ideally I know you'd like a native API for Android to consume Channel API messages. You can vote for this issue but I unfortunately can't provide an ETA for it: http://code.google.com/p/googleappengine/issues/detail?id=4189

for multiplayer online game: how to initiate data transfer by server and send data to android phone?

I'm very familiar with REST type of communication where the phone sends GET and POST messages to the server - essentially polling the server for updates. This worked well for apps where real-time data wasn't essential.
For a multiplayer game real-time data is essential; after a user has signed-in to the server the server needs to be able to send messages to the phone (instead of the phone asking for data).
Does anyone have any links to provide details on how this is done ?
Thanks to Selvin for pointing me to the "socket" keyword.
I've searched around and came up with the following online resources :
Incorporating Socket Programming into your Applications
http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/
Example: Android bi-directional network socket using AsyncTask
Example: Android bi-directional network socket using AsyncTask
If anyone has a book suggestion, please let me know with a comment.
You will need to implement Android Cloud to Device Messaging, Android's push technology, available on Android 2.2 and above.
http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html

Using XMPP over GTalk to simulate push notifications

I'm currently writing an Android application that should be able to receive push notifications from another application hosted in Google's App Engine.
Since I can't use sockets in GAE, I though maybe using XMPP over GTalk server would solve my problem. But that way the Android Application would be connected to the users Gtalk account and thus showing the user as being online, when in reality the user is not.
Any way of achieving this kind of communication without showing the user as being online, and without asking the user to create a separate account?
Or any free push notification alternatives?
EDIT:
I'm targeting 1.5+ Android devices so C2DM isn't an option.
Thanks!
May be you can use the channel API: Building real-time web apps with App Engine and the Feed API
Not sure about the exact requirement of your app, but.. perhaps C2DM can be an alternative?
http://code.google.com/android/c2dm
I've found the PubNub service (http://www.pubnub.com/).
It enables push notifications through API's on several platforms (PHP, Ruby, JavaScript, Java, ...).
It's a paid service, but provides a free daily quota.
Although it's not the ideal solution to my problem, it'll have to suffice until some Channel API documentation comes out.
Thanks to all of you!
Why are you shying away from HTTP/JSON? Might be useful to know why you discounted the obvious solution...

Categories

Resources