2

How does Whatsapp keep its connection to the socket when the app is totally closed off.

Does Whatsapp use GCM or APNS push to trigger the App to sync with the Ejabberd?? Some people say it always stay connected(I am pretty new to this) but i tested i rebooted my phone, clear ram, AppManager forced close Whatsapp, it still receives the messages. So wondering can you make code runs on the OS level to keep the connections when everythings closed? Or it just use the GCM for triggers?

Isnt the only connection the phone has is the Android GCM when no app is running in the background?

I am very confused, if Whatsapp does use XMPP protocol, how does the App stays connected to the server when it is totally closed out?

I have researched further, found Pubnub is running something similar with TCP or XMPP protocol and can research messages while the app in the background.... But NOT IOS. http://www.pubnub.com/knowledge-base/discussion/381/can-my-ios-app-receive-messages-while-inactive

It requires the APNS push to wake the app up first then to reestablish the connection. But how about Whatsapp? Seems like Appstore compliance problem? But AppStore allow many apps to run in the background, but doesnt it allow Pubnub or Apps that have a connection to stay alive in the background?

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44
John
  • 983
  • 1
  • 13
  • 31
  • 2
    Probably kept as a service, see http://developer.android.com/guide/components/services.html – Galax Jun 23 '15 at 16:50
  • Hi Thanks, i had a look, but when you keep it as a service it just run in the background right? But when i am playing with Whatsapp, i tried to close it out from App manager then clear ram, and it still receives the messages instantly. – John Jun 24 '15 at 07:58
  • Hi. I think you're asking for different things. In the case of iOS, the app receives push notifications through the APNS. If you have deactivated app background refresh (which didn't exist until recently), notifications still arrive. When you open the app then whatsapp asks for the new data. – lnjuanj Jun 24 '15 at 08:57
  • Ah ok, thanks, so the APNS "kind of" triggers the XMPP connections to sync, eJabberd in whatsapp case – John Jun 24 '15 at 11:41
  • Whatsapp does not keep connected, session suspended on their server and it resumed when user opens app again – vitalyster Jun 25 '15 at 12:15
  • But whatsapp does receive messages when you just boot up the phone tho. Or force close the app though. – John Jun 26 '15 at 11:27
  • It isn't whatsapp itself, but gcm notifications – vitalyster Jun 29 '15 at 05:23

1 Answers1

1

To build a chat application on iOS, you will be disconnected after a few minutes in all case. What you have to do is to rely on Apple Push Notification service to let the user know new messages have been received.

It means that you have to make sure ejabberd is modified to be able to leverage push notification service and not only rely on XMPP connection being available to tell the user about new messages.

Mickaël Rémond
  • 9,035
  • 1
  • 24
  • 44