简体   繁体   English

即使应用程序在后台运行且未打开,WhatsApp如何知道用户是否获得了推送通知?

[英]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... 我得到了一个答案,当应用程序在后台并且用户没有打开时,无法知道推送通知是否到达iPhone ...

But I found something interesting: I take 2 iPhones with WhatsApp. 但我发现了一些有趣的东西:我用WhatsApp带了2部iPhone。 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. 我打开,在第一部iPhone,WhatsApp并退出它(WhatsApp现在在后台),然后用第二部iPhone,我发送WhatsApp按摩到第一部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). 当WhatsApp的推送通知到达第一个iPhone时,我可以在消息附近看到两个“V”(符号)(我不打开推送通知)。 After this I close the Internet & 3G in the first iPhone and again send WhatsApp message with the second iPhone to the first one. 在此之后,我在第一部iPhone中关闭了互联网和3G,并再次将WhatsApp消息与第二部iPhone一起发送到第一部iPhone。 - and I can see only one "V" near to the massage (not read - not get push notification). - 我可以看到按摩附近只有一个“V”(不读 - 不通过推送通知)。

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). 现在,在第一部iPhone上重新启用互联网后,我收到推送通知后,我可以看到两个“V”(再次 - 我不打开推送通知)。

How does it work? 它是如何工作的? How does WhatsApp know whether the iPhone gets the push notification or not while the WhatsApp works in the background? 当WhatsApp在后台运行时,WhatsApp如何知道iPhone是否收到推送通知?

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 让我们在关闭WhatsApp应用程序的情况下调用iPhone - 接收器和您发送消息的其他iPhone - 发件人 ,让我们使用通用术语应用程序而不是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. 所以,我猜(我不知道 - 我与WhatsApp无关),你得到的双v图标是应用程序消息到达接收器的应用程序时 - 与推送通知无关。

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. whatsapp软件在后台运行,在特定端口上侦听传入消息。 It does this continuously. 它不断地这样做。

BTW : BTW:

One V = message delivered from your mobile to the whatsapp server 一个V =从您的手机发送到whatsapp服务器的消息

Two V's = message pushed from whatsapp server to recipient mobile 两个V =从whatsapp服务器推送到收件人移动设备的消息

Blue V's indicate message has been read 蓝色V表示已读取消息

Whatsapp doesn't show if the person reads the message or not. Whatsapp不会显示该人是否阅读该消息。 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). 它只是通知消息何时被发送到whatsapp服务器(一个V)以及何时发送到人员电话(2个V)。 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. 双重并不意味着消息被读取它只是意味着whatsapp连接到手机并且能够传递消息。

After receiving a push notification the receiver can download data from a URL that you include in the payload of your push notification. 收到推送通知后,接收方可以从推送通知的有效负载中包含的URL下载数据。 By requesting that URL the server knows that the receiver received the push notification and can pass this status on to your sender application. 通过请求该URL,服务器知道接收方收到了推送通知,并且可以将此状态传递给您的发送方应用程序。

Like so: 像这样:

  1. Add a specific URL in your push notification payload 在推送通知有效内容中添加特定URL
  2. Implement the application:didReceiveRemoteNotification:fetchCompletionHandler: method in your app delegate and in that method call the URL from the payload. application:didReceiveRemoteNotification:fetchCompletionHandler: method程序委托中实现application:didReceiveRemoteNotification:fetchCompletionHandler: method ,并在该方法中调用有效负载中的URL。
  3. Implement a logic on your server that recognizes the URL call as a received notification 在服务器上实现一个逻辑,该逻辑将URL调用识别为已接收的通知
  4. Let your sender application continuously get the current notification status from the server. 让您的发件人应用程序不断从服务器获取当前通知状态。

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). 如果Whatsapp最近关闭,它仍然在后台运行,仍然可以收到消息(因此回执)。 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. 但是,在应用程序暂时闲置(或其他应用程序具有更高优先级)后,Whatsapp将被终止,然后它将不再接收传入消息并且不会返回收据。

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? 那么为什么它在后台运行时返回收据呢?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 即使应用未运行(即使不是在后台),我的设备上是否也收到推送通知? - Are push notification received on my device even if the app is not running (not even in background) ? 知道用户何时从我的应用程序“读取”推送通知吗? - Know when user “reads” a push notification from my app? 当应用程序在后台时推送通知 - Push notification when app in background 即使应用程序未在后台运行,也可以自动打开应用程序的VoIP推送通知是否可以在iOS中使用? - VoIP push notification that opens app automatically even if app is not running in background is it possible in iOS? 当app在后台时,如何对接收推送通知执行操作? - how to perform action on receive push notification when app is in background? 将通知推送到我的应用而非用户 - Push Notification to my app not the user 用户在后台收到推送后手动打开应用程序时获取推送通知有效负载 - Getting push notification payload when user opens app manually after push has been received in the background 具有应用程序背景的iOS远程推送通知 - iOS remote push notification with app background 应用程序在后台 swift 3 时的远程推送通知 - remote push Notification when app is in background swift 3 推送通知应用程序背景iOS 9 swift - push notification app background iOS 9 swift
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM