0

I am currently working on android chatting app using io.socket. When the app opened all the thing is working fine but when I kill the app I am not able show messages.

  1. GCM is a bad idea for messaging because I heard it misses some messages.
  2. service means it will kill the battery.

I want to show messages even if I kill the app(just like watsapp).

Do you have any suggestions, as to, how I can achieve this.

sachin.g
  • 31
  • 8
  • Mmm... if you are using sockets... just don't close socket when app is closed, use a `backgroundService` to keep your `socket` opened, It could be a solution – Aspicas Jul 19 '16 at 06:26
  • for whatsapp it is running one service like MessageService if you kill the app also it will be in running, so from that service you are getting message – Hanuman Jul 19 '16 at 06:33
  • They connect application with server anytime. – Hiren Patel Jul 19 '16 at 06:34
  • Use Quickblox, https://github.com/QuickBlox/quickblox-android-sdk for chatting, they are providing good interface for chatting – Hiren Patel Jul 19 '16 at 06:42
  • You have to use Background Service http://stackoverflow.com/questions/12219249/background-service-getting-killed-in-android – mesutpiskin Jul 19 '16 at 06:45
  • I have tried quickblox they are using gcm to receive message.when the app is in pause mode.But not after killing the app.after killing the app it wont receive messages only. – sachin.g Jul 19 '16 at 07:13

1 Answers1

0

When you kill whatsup app its use Gcm and when you Open your Application its uses XMPP protocol to send and recieve Message. Whatsup app using this both feature in it. so It getting message after killing app too. Whats app app also use MessageService after killing app so It get message regarding.

Jitendra
  • 3,608
  • 2
  • 17
  • 19
  • Thank you for the reply.Can you please tell me more on message service any example. – sachin.g Jul 19 '16 at 07:11
  • message service make by extending service class. you can put your message recieve code here . – Jitendra Jul 19 '16 at 07:37
  • Thank you i have created the service and i can connect to the socket server after killing the app also.But one more problem occurred.first i will open the app with internet and can send message.then i will switch of internet i will try to send a message wont send ok.Then i will switch on the internet message is not getting sended.How to reconnect the socket once the internet comes. – sachin.g Jul 21 '16 at 05:28
  • Android provide Conectivity Reciever so We can track when internet on or off. when we get internet on we have to manually check in table what message need to resend. then do resend – Jitendra Jul 21 '16 at 06:57