Jeeten Parmar
Jeeten Parmar

Reputation: 5757

What should I Use for push notification in android

I have android application such a way that If user send feedback to another user then that receiver user gets notification about it, same like whatsapp.

What should i use for that ?

If Google Cloud Messaging good option or anything else is there ?

Upvotes: 1

Views: 103

Answers (1)

Sadegh
Sadegh

Reputation: 2669

Three approaches:

  1. Polling. It means your client application should periodically send request to server to get new Events. [ bad bad approach!]
  2. Steady connection. Your client application have a steady connection and list for server notifications. [inefficient for battery]

    • Because HTTP protocol is just for request-response, it's tricky to handle push. you have to have two connection to communicate with server. one for requests and another for handling server's events. you make a keep-alive connection to server, and server does not respond until it has some events for you, as soon as your client get the response(which is not actually a response!) your client must send another request to server to listen for future events. XMPP protocol is a good option for this approach. there is also a java library called Smack and and android optimized ported library called aSmack. you must have an XMPP server too.
    • Use WebSocket protocol which provides providing full-duplex communications channels over a single TCP connection. There is an android library called android-websockets (and other java libs!)
  3. Google Cloud Messaging known as GCM

I think a combination of GCM and WebSocket is a good approach.

Upvotes: 1

Related Questions