3

Whatsapp enabled whatsapp web for ios. I reviewed the whatsapp web on ios, it works well but how? I turned off background app refresh, then closed the whatsapp app. Then I tried to use whatsapp web and it worked well. When I disabled the internet connection of my iPhone, whatsapp web said "your phone connection lost" How whatsapp did know this? How whatsapp works in background even when it's closed?

Tolgay Toklar
  • 4,151
  • 8
  • 43
  • 73
  • 2
    just guessing here, but ye as Ben said, maybe when a message is sent via the web, a push notification is sent to your phone, which would allow it to make a webservice call to the server, if server doesnt receive message, then assumes your phone is disconnected. – Fonix Aug 20 '15 at 07:54
  • @RoNiT, Your duplicate post is 5 days newer than this one, So may I suggest you to write there this comment. – Iman Nia Sep 01 '15 at 21:08

2 Answers2

4

Regarding how it works even when WhatsApp is closed from the multitasking screen, it is likely taking advantage of iOS 8's support for the new VoIP push messaging service.

https://developer.apple.com/library/prerelease/ios/documentation/Performance/Conceptual/EnergyGuide-iOS/OptimizeVoIP.html

Note how "In the past ... if a user quit the VoIP app, calls from the server could no longer be received" but with the new method "Your app is automatically relaunched if it’s not running when a VoIP push is received."

WhatsApp now offers VoIP calling in its app, so it does have legitimate use of these types of push messages. Whether it's considered an abuse of the VoIP push message privilege to start the app in the background, not for a call but to sync messages to the web, I'm unsure of, but this certainly seems the most likely explanation for how it manages it.

Steven Darby
  • 148
  • 7
  • 1
    shouldn't the Red Bar appear at the top in that case? But in case of whatsapp it doesn't appear – rahulg Aug 28 '15 at 13:02
  • No, the red bar is when your phone is recording either audio or the screen, and not related to background VoIP calls or push messages. https://support.apple.com/en-gb/ht207354 – Steven Darby Jun 14 '18 at 16:02
  • Updated question and answers in 2020/21 for iOS 13: https://stackoverflow.com/questions/60815763/how-does-the-whatsapp-web-client-still-work-with-the-latest-ios-update-sdk-vers – nishanthshanmugham Mar 07 '21 at 12:48
1

Just guessing too, but surely it has to be with silent push notification method to wake up the app and exchange some data with the web client API, I'm waiting for more technical details about this mechanism, it seems to be very useful for any other applications and use cases

ADDED INFO:

I've been investigating a little bit more about it, and that's what I've found:

  • First, WhatsApp has enabled the possibility to have more than one session opened for the same user, which was not possible before the release of WhatsApp Web, as far as I know.
  • Second, when the QR code is scanned and validated, the Web Client of WhatsApp Web connects with a newly launched process (probably at WhatsApp server's infrastructure) which we'll call FakeClient. FakeClient establish a new session with WhatsApp behaving as a classic mobile client and interacting with it in the name of the user. So, the WhatsApp Web Client doesn't connect directly with WhatsApp's servers but with the FakeClient.
  • Third, FakeClient exchanges messages between the Web Client and the servers, but it also receives pings from the iOS app saying "hey! the user is alive" and syncing the message history generated in the Web Client with the iOS app. This is even possible when the iOS app is running in the background thanks to the Background Fetch feature. https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
  • Finally, when "FakeClient" stops receiving "pings" from the iOS app, it notifies the Web Client about the disconnection, so the proper message is shown.

The more interesting thing here is how the app is able to keep the connection alive even when the app is strictly closed (throwing it out from the multitask screen). It seems like some kind of special permission has been granted from Apple to this app in order to allow this behavior, AFAIK currently there is no documented way to achieve this.

jmirandac
  • 29
  • 5
  • This isn't quite right WA Web creates a connection to the Phone bounce throw the WA servers. It exchanges the Messeage directly with the Phone. But requests Presence directly from the WA Servers. https://github.com/wiomoc/whatsappweb-rs – wiomoc Nov 16 '18 at 12:10