69

WhatsApp implemented end-to-end encryption (whitepaper) in their latest update.

How is it possible for WhatsApp to send push notifications with message contents to the Apple Push Notification service?

One possible solution would be to send the unencrypted message to APNs from within the app itself but this would be open to abuse and would defeat the purpose of end-to-end encryption.

Update:
I have just tested it a bit more, according to Apple's documentation:

However, the system does not automatically launch your app if the user has force-quit it. In that situation, the user must relaunch your app or restart the device before the system attempts to launch your app automatically again.

Which I tested, and resulted in me still receiving the plain text push notifications. This would lead me to believe the app is not running in the background to decrypt any notifications received and then repost them.

Update May-2017:

I have now used the VoIP API ( as mentioned in the answers below ) to effectively achieve the same result myself in a demo app. Works very well.

Update July-2017:

Apple no longer allows the usage of the API for push notifications of non-VOIP apps. They do however allow WhatsApp to do it in their infinite fairness.

Update September 2018:

A notification application extension can now be used to decrypt push notifications. However, dynamic libraries are discouraged from use in such extensions so you must have a codebase that can be compiled statically for decryption etc.

70

WhatsApp could be using VOIP background mode along with PushKit for solving this problem.

Voip pushes are:

  • delivered directly to the app.
  • considered high-priority notifications and are delivered without delay.
  • delivered even if the app was force-quit by the user.

For details refer to Voice Over IP (VoIP) Best Practices

Once the encrypted payload of VOIP push is decrypted they show a “Local Notification” with the decrypted message.

There is one small issue though, PushKit is available only on iOS 8 and later. So, how is Whatsapp doing it for earlier versions of iOS? Well, it isn’t. They don’t allow you to see message preview in notifications on versions earlier that iOS 8 (Verified it on iOS 7, see screenshot)

Whatsapp Settings in iOS 7

  • 2
    Just to be clear, this is still conjecture, right? It's a very good explanation and the difference between versions is a nice piece of circumstantial evidence, but it sounds like we still don't know for sure. – octern Apr 6 '16 at 19:28
  • @octern I am planning on attaching LLDB to whatsapp once I get my hands on a jailbroken iphone – Antwan van Houdt Apr 6 '16 at 23:24
  • That makes perfect sense. But why does Threema still claim that there is a technical limitation? Or are they just slow/lazy updating their software? – mrclschstr Apr 7 '16 at 10:50
  • 1
    I just wonder why they don't show the name you gave to the contact instead of the username of the sender. Before this feature it was fair, but now its completely possible to show the contact. – Gonzo May 8 '16 at 0:10
  • 1
    In iOS10, WhatsApp may be using Notification Service Extensions, using this extension app can receive payload in background, modify/decrypt it and then show it to user. – D4ttatraya Jan 9 '17 at 13:41
9

What you call Push Notifications (the ones you see in your notification center) are not exactly the same thing as Remote Notifications (the ones sent via APNs).

On Android the two are totally different. First one is called Notification, the second one is called Message or Downstream Message.

But back on iOS the application can generate Local Notifications that will show in your notification center. These don't need to be triggered by any remote notification, it's up to the logic in the app to do it and iOS apps do have the possibility to perform background tasks and sync that can generate these notifications.
Since iOS7, an iOS application can also perform HTTP operations in background for unlimited time (because the application is delegating the network transfer to the system, that will awake the app for a limited amount of time when the transfer is finished).

Remote Notifications, on the other hand, were first designed to send a push directly for APN to the user. But Apple realized the need for developers to send push notifications to their application rather than to the notification center and added a silent flag to Remote Notifications so that the server can send a notification to wake the application without disturbing the user. The application will then perform some synchronization and logic and decide itself to create Local Notications or not (that will show in the notification center).
Besides, Remote Notifications' payload suffered a limit of 256 bytes until recently, which forced many developers to use these notifications as a Push-to-sync message rather than as a data channel.

If you understand me well, then you understand that Whatsapp does not need to send the message payload in the Remote Notifications using APNs.

  • 2
    I like this answer. I will upvote if you manage to add some references. – GnP Apr 13 '16 at 21:37
  • @gnp Here you go. – Thibault D. Apr 14 '16 at 8:21
  • Apple's documentation on silent notifications is here: developer.apple.com/documentation/usernotifications/… - and it has the following comment: "The system treats silent notifications as low-priority. You can use them to refresh your app’s content, but the system doesn't guarantee their delivery... ... don't try to send more than two or three silent notifications per hour. " I don't think this would be the avenue that Whatsapp would be using – Orion Edwards Sep 6 '18 at 2:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.