3

I've faced a problem of writing a backend on Java for the chat with Android clients. What are the best practices for it? After quick googling i've found some approaches:

  1. Polling / long polling.
  2. c2dm. Seems like an easy variant, but i'm afraid of message size limitation (1024 bytes). Also, users must have Google account to use this technology. It might be a problem for using other platforms (iOS, WP7)
  3. Sockets. Can i use them with Tomcat or Glassfish? Are there any troubles on Android?
madhead
  • 31,729
  • 16
  • 153
  • 201
  • 1
    these days you simply use PubNub, it's almost inconceivable you'd bother with any other approach – Fattie Feb 19 '17 at 12:47

1 Answers1

2

Why not use a combination of C2DM and then that opens the app which does a poll for the data. C2DM is not designed for huge payloads but can tell the app to poll and so will be realtime.

WP7 and iOS have a C2DM equivalent with the same sort of payload restrictions but they could then share the same backend API for the poll?

Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
  • iOS dont force you to set up an account to send you a push notification. It uses the UUID of the phone, thats why it work so smooth. I would definitely have chosen that option for iOS but not for Android. – Finn Larsen Oct 05 '11 at 11:54
  • So i design an interface to c2dm (or its variants). I implement it for every platform i use (Android, iOS, ...). Through this interface i send only short notifications about updates. And when users receive them, they should fetch latest messages from the server. Am i right? I think this is a good enough solution for me, thanks for the idea! – madhead Oct 05 '11 at 12:05