Question

Okay here is my problem where i am stuck for so many days.

I am developing a simple chat application with the help of XMPP client - SMACK. Everything works fine for me normal chat process from one friend to another, also added the notification part.

What i am not able to do is if i forcibly close my application the whole session with SMACK stops.

I am not able to send the message to the user who had closed the application. Now, how do i keep the status of the user permanently online so the he can also receive messages even if he had closed the application.

Was it helpful?

Solution

You can't. If the application is closed, the user is no longer online and the server knows that. You can still send them messages, but it is the servers job to store offline messages, but that means the server has to be configured to do so.

They can be retrieved once the user connects again.

OTHER TIPS

Here are a couple of suggestions to work around the problem

Have a go at implementing either:

  1. A long running service that connects every x minutes (polling solution) I personally advise against this as it's a drain on network and battery.

  2. Implement GCM in your app and server. It wakes up the app when a message is sent and connects to the server to retrieve the payload. (in fact with GCM over C2DM you can send the payload over google and not even have to connect but I steer clear of this)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top