How does WhatsApp know if the user gets the push n

2019-03-15 20:23发布

问题:

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?

回答1:

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.



回答2:

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



回答3:

Whatsapp doesn't show if the person reads the message or not. It just informs when the message has been sent to the whatsapp servers(one V) and when it has been sent the person phone (2 V's). The double does not mean the message was read it just means that whatsapp connected to the phone and was able to pass on the message.



回答4:

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.


回答5:

The above posters are all correct. Just to add one more thing. If Whatsapp has recently been closed, it is still running in the background and can still receive the message (hence the return receipt). However, after the app is left unused for a while (or other apps have higher priority) Whatsapp is terminated, then it will no longer receive incoming messages and will not return receipt.

Of course the observant person would notice a small lag between opening the app and the new messages being displayed which seems to suggest the messages are not downloaded in the background but only downloaded upon opening the app. So why does it return receipt while running in the background?