JavaForAndroid
JavaForAndroid

Reputation: 1179

Android XMPP - Server side

I try to learn real time communication between Android and a web server. The communication should work with XMPP and GCM. Now I need help on the server side. What should be used for push notifications on server side? What has the best performance? I thought about PHP in combination with GCM. Or are there better alternatives? The data should be stored on the webserver in a MYSQL database. I have already searched but there were to many different solutions so that it was confusing.

Upvotes: 0

Views: 1042

Answers (1)

Drewness
Drewness

Reputation: 5072

Google Cloud Messaging is now the preferred method of sending messages to applications running applications, since the depreciation of Cloud to Device Messaging.

Like you mentioned however, there is XMPP as well which happens to be my favorite at the moment.

It's powerful, fully featured, extendable and there are even opensource solutions out there should you want to host it on your own box. If you do, I recommend OpenFire.

Just to wet the appetite, here are some benchmarks for battery life using XMPP:

The Android client must maintain a persistent TCP connection by waking up periodically to send a heartbeat to the XMPP server. This clearly imposes a cost in terms of power usage. An estimate of this cost is provided below:

  • Using a 1400mAh battery (as supplied in the Nexus and HTC)
  • An idle device, connected to an 3G network, uses approximately 5mA
  • The wake-up, heartbeat, sleep cycle occurs every 5 minutes, takes three seconds to complete and uses 300mA

The cost in battery usage per hour is therefore:

  • 36 seconds 300mA = 3mAh sending heartbeat
  • 3600 seconds 5mA = 5mAh at idle
  • 4:95 + 3 = 7:95mAh combined
  • A 1400mAh battery lasts approximately 11.6 days at idle and 7.3 days when running the application, which represents an approximate 37% reduction in battery life.
  • However, a reduction in battery life of 37% represents the absolute worst case in practice given that devices are rarely completely idle.

Upvotes: 3

Related Questions