Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How whatsapp web works on iOS? [duplicate]

Tags:

ios

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?

like image 298
Tolgay Toklar Avatar asked Dec 30 '25 23:12

Tolgay Toklar


2 Answers

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.

like image 101
Steven Darby Avatar answered Jan 02 '26 16:01

Steven Darby


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.

like image 42
jmirandac Avatar answered Jan 02 '26 16:01

jmirandac



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!