Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does WhatsApp know if the user gets the push notification even if the app is runnng in the background and is not open?

I have already asked related question: any option to know if apple app get the push notification?

And I got an answer that it is not possible to know if push notification comes to the iPhone when application is in the background and the user does not have it opened...

But I found something interesting: I take 2 iPhones with WhatsApp. I open, in the first iPhone, WhatsApp and exit it (the WhatsApp is in the background now), then with the second iPhone, I send WhatsApp massage to the first iPhone.

When the push notification of WhatsApp reaches first iPhone I can see two "V" (symbols) near to the message (and I don't open the Push notification). After this I close the Internet & 3G in the first iPhone and again send WhatsApp message with the second iPhone to the first one. - and I can see only one "V" near to the massage (not read - not get push notification).

Now after re-enabling the Internet on the first iPhone and after I get the push notification I can see two "V" (again - I don't open the push notification).

How does it work? How does WhatsApp know whether the iPhone gets the push notification or not while the WhatsApp works in the background?

like image 621
user1273189 Avatar asked Mar 17 '12 13:03

user1273189


People also ask

How does WhatsApp receive messages when app is closed?

The server records the phone and port numbers in the message and the IP address that the message came from. The server sends an acknowledgement to the app. The app receives the acknowledgement and closes the message socket. A message with your phone number as the destination comes into the server.

Why do my WhatsApp messages only come through when I open the app?

Make sure Do not disturb is turned off or you have allowed WhatsApp notifications in priority mode in your phone's Settings app > Sound > Do not disturb. Make sure all of WhatsApp's permissions are granted in your phone's Settings app > Apps > WhatsApp > Permissions.


3 Answers

After receiving a push notification the receiver can download data from a URL that you include in the payload of your push notification. By requesting that URL the server knows that the receiver received the push notification and can pass this status on to your sender application.

Like so:

  1. Add a specific URL in your push notification payload
  2. Implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method in your app delegate and in that method call the URL from the payload.
  3. Implement a logic on your server that recognizes the URL call as a received notification
  4. Let your sender application continuously get the current notification status from the server.
like image 189
Manuel Avatar answered Oct 07 '22 16:10

Manuel


What you mean is just the basics of push-technology :

The whatsapp software runs in the background listening on a specific port for incoming messages. It does this continuously.

BTW :

One V = message delivered from your mobile to the whatsapp server

Two V's = message pushed from whatsapp server to recipient mobile

Blue V's indicate message has been read

like image 32
Vincent Snijder Avatar answered Oct 07 '22 17:10

Vincent Snijder


Let us call the iPhone with WhatsApp application closed - the receiver and the other iPhone you send messages with - the sender, and let us use generic term application instead of WhatsApp

The application at the sender is not able to learn that push notification has reached the receiver. It is by the nature of push notifications.

However, the sender is possible to send another - not a push notification, but prioprietary protocol - message to the application at the receiver which it (the receiver) is welcome to acknowledge to the sender in any application-specific way it wants.

So, I would guess (I don't know - I'm not affiliated with WhatsApp in anyway) that the double-v icon you get is when application message reaches the application at the receiver - and has nothing to do with push notification.

like image 34
Krizz Avatar answered Oct 07 '22 17:10

Krizz