I am looking for an optimal solution to implement chat server for android clients on GAE.
At the moment I use C2DM to notify particular users about new messages and pull data from server after such notification. But sometimes C2DM servers delay notification message and it stops to be realtime.
I also had a look on XMPP and it seems that it is mandatory to have an external XMPP server like google talk, so it is not what I am looking for too.
Is there another way to implement chat on GAE? Any advices are warmly appriceted!
The Reason why you are experiencing Delay with C2DM is because it is not real time. Google actually says this: It isnt the most reliable way. It suggest having a third party server such as XMPP
You can implement chat on App Engine using the Channel API, but the only supported clients for that are browsers. If you're prepared to make your Android app browser-based, that would be a solution - otherwise, you will have to look into third-party services, like Urban Airship.
Related
I am currently writing an Android app, and I would like to send push notifications from my server to the phones where this App will be running. Due to security reasons, I would like to avoid any third party server like Google's servers that are used when using GCM (Google Cloud Messaging). How can I achieve that? Or do I need to use a workaround (e.g. polling or working with GCM and encrypting the messages)?
Thank you very much in advance for your help!
The easiest way to prevent Google from reading your messages is simply not sending any data to GCM. Use send-to-sync-messages for that. To improve performance use collapse_key.
On receipt of a send-to-sync-message fetch the new data from your webservice. I also used this approach in a recent project with high security requirements.
I want to implement an instant messagign service analogously to whatsapp.
The messages are delivered, even thoug sender and receiver do not need to be online at the same time.
Is there a framework existing to do so (btw I use a linux server). Is the Google Clouse Service suitable for this? Thank you
Google Cloud Messaging (GCM) is a service that manages small messages to / from android. It does require users to be using google play.
What makes it so cool is they will manage the connections for you. They will queue stuff up for a period of up to four weeks, and after that will send a message telling you that its been more than weeks, and you will need to process a new request to obtain the original messages again.
Its a free service. There are some rate limits, but they seem pretty reasonable. i.e. You can't use it for sending frequent game moves, but its totally fine for normal text messages. As I understand it, GCM is only a server interface. You will have to roll your own XMPP server to store and manage messages. Note: there is a payload limit on GCM messages, I think its 4k or so... not big enough for images. You'd have to manage those via http, and send image names via GCM.
They will also broadcast messages to users (1000 at a time). Did I mention this is a free service?
Something like this link will get you started. The API keys thing and registration #'s is sorta confusing. Once you figure that out, it all works. You can test to your emulator via curl messages to the google server, etc..
Oh, and GCM also keeps track of all your user analytics as well..
You can try openfire. It has offline message and everything. Server can be hosted in linux as well.
There is Layer (Android and iOS support for the moment)
Hey Checkout this easy way to implement chat
Quickblox Api
I really tried to find a solution to this problem but didn't. There are some threads related to this concept, but I didn't find a comprehensive solution.
I have a server with Openfire which sends messages. When both users are online, there is no problem. However, when a user is offline I would like to send a push notification, as in Whatsapp. I heard that Whatsapp and other IM apps use a modified version of ejabber to send push notifications, but couldn't find out how.
One possibility is to use GCM, but I am not sure if this is the right way to go. Also I would like to avoid polling, for the sake of not draining battery life.
Does anyone know some solution to this or has an example?
I am studying the openfire and found some good options that I would like to share with you.
I found a plugin in github and i will test it this week. It seems that will be a good solution to your goal and to my: https://github.com/meisterfuu/Openfire-GCM/
Another option is to use CallbackOnOffline Plugin that calls a specified URL with To and From parameters. This url could be a endpoint in your web service, and with that data (To and From) you could get the associated Id for push in your base, and did a push.
https://www.igniterealtime.org/projects/openfire/plugins.jsp
Well, you could use GCM with XMPP.
The new GCM Cloud Connection Server allows you to use the XMPP protocol for a bidirectional (Cloud to Device and Device to Cloud) communication between your server and your Android application.
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.
In openfire its done automatically, messages will be recieved by the user when the user gets online. So no worries send message to an offline user and when the user comes online message will automatically pushed to the user.
What is the best way for 2 android clients to communicate over gae? Sometimes my server app(on GAE) has to send push notifications to clients. I have tried Channel API on javascript clients. C2DM services seems not be a good solution at this moment.
Does any have some suggestions for me?
I think this is currently not possible with GAE. The Channel API is only for used in Browsers.
But you could use a 3rd party pushing service for that (have a look at http://pusher.com/ or http://www.pubnub.com/) and combine this services with the GAE services (like the Datastore or Task Queue).
How can I send data from a server to an Android device without the device polling for data?
This is called a server side 'push' and is commonly referred to as 'pushing'. This is a well known feature of the iPhone, however, it does not currently exist on the Android. Android Cloud 2 Device messaging has not yet been released to the general development community. you may want to check out projects such as MQTT and Deacon.
You might consider using Googles cloud to device messaging for a solution.
You'll have to sign up for an account and are only able to use AppEngine servers at the moment.
Your application has to use API level 8 (2.2) in order to be able to receive the cloud's pushes.
GCM (Google Cloud Messaging) is the easiest way, and while GCM provides the basic service of sending messages, there are companies out there that do help you get up and running.
You could take a look at companies like urban airship, xtify and mBlox (developer.mblox.com) to get started with this and have a few additional tools that help you structure the push notifications in a more structured way.
Good Luck with your development!