How is whatsapp fetching message in background in windows phone?

3.5k views Asked by At

After the latest update of Whatsapp on Widows Phone Store, I have noticed that now, once they show the toast of message on my device, then they mark the message as delivered (notify the sender that the message has reached my device).

After I let the toast notification go away, I switched off all my data connection and opened Whatsapp and found that that particular message in my app. This is happening consistently on both wp7 and wp8 device. This was happening even when I had disabled background agent! Beside background agent of an app does not run all the time.

So my questions is, on windows phone platform, where the app is not allowed to run in background all the time, how is Whatsapp application getting those messages? Is it using any particular api/hack to get(in app) those messages when it's not on foreground.

3

There are 3 answers

3
Anobik On

Go through this link

Push notification for Windows Phone

What will help you to understand is

The server maintains a maximum of 30 notifications (regardless of type) for each URI. Once the limit of 30 is reached, all new messages sent to the server are discarded until the device reconnects and the queue can be flushed.

0
Anton Thushara On

In windows phone there is something called raw notifications, these are different from push notifications, push notifications display a notification, but raw notifications triggers a background task that can run under certain api restrictions for about 15 seconds. (I think, I'm not sure about the time duration), I think what whatsapp does is that it downloads the message and saves it in a local database which is maintained in the device. When whatsapp is opened it will read the local database and also sync with the server.

Please correct me if I am wrong.

0
Milan Aggarwal On

The question you have asked has two parts: one for wp7 and the other for wp8. I will anser each one by one.

Windows phone 7

Based on my research, I have found that whatsapp is still using audio streaming api on wp7 devices to stream messages in the background i.e. when the app is not running. Whatsapp was criticized of using this API as constantly using this causes battery drainage as well as hampers the music experience of the user.

Windows Phone 8

Once whatsapp moved to wp8 they stopped using the Audio API and moved to VOIP API. Note that whatsapp doesn't use VOIP for any purpose but their manifest shows usage of VOIP api, and after reading many articles I have come to the conclusion that they are using this API to activate background agent and pool messages in the background.

While sending raw push of type 4, the background agent for VOIP is activated in which you can practically do anything from reading the payload to establishing a new socket connection subjected to restriction on usage of certain APIs

I have also found out that even if a user disables bg agents for an app some essential bg agent still continue to run for eg bg agents in audio stream API and VOIP API.

I hope this answers your question.