Apple 多个推送通知在通知托盘中不可见 [英] Apple Multiple Push Notifications not visible in Notifications Tray

查看:20
本文介绍了Apple 多个推送通知在通知托盘中不可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上想让同一个应用程序中的多个推送通知在 iOS 的通知托盘中可见.

I basically want to make multiple push notifications in the same application visible in the notification tray in iOS.

如果在通过 APNS 触发推送通知时我的数据处于打开状态,则此方案有效,但如果我处于离线状态并在一段时间后返回,则只会收到最新的数据.APNS 文档确认了此功能.

This scenario works if my data is on while push notification is triggered via APNS, but only the latest one is received in case I am offline and come back after a while. This functionality is affirmed by APNS documentaion.

然而,这在 WhatsApp 中是有效的:

However, this is what worked in WhatsApp:

  1. 关闭数据连接
  2. 向 WhatsApp 发送了一些消息
  3. 打开数据连接
  4. 在 Apple 的通知托盘中看到多个推送通知

这个场景如何运作?我可以为此使用 APNS 吗?如果是,那么如何?

How's this scenario working? Can I use APNS for this? If yes, then how?

参见 微信中多个推送通知的示例图片.

推荐答案

就像您在问题中所写的那样,Apple 文档中提到了这一点:

Like you wrote in your question, this is mentioned in the Apple Docs:

如果您向同一设备发送多个通知或计算机在短时间内,推送服务将发送只有最后一个.

If you are sending multiple notifications to the same device or computer within a short period of time, the push service will send only the last one.

链接

您所描述的唯一情况是,如果您的 WhatsApp 在获取那些 推送通知 时在后台打开.这样 WhatsApp 会将它们作为 local 通知 处理,并将它们全部显示在通知中心.如果 WhatsApp 已关闭,您将像任何其他应用程序一样只收到最后一条通知.

The only scenario that what you're describing will work is if your whatsApp was open in the background while getting those push notifications. That way whatsApp will handle them as local notifications and will present all of them in the notification center. If whatsApp was closed you'd get only the last notification like any other app.

您可以轻松地对此进行测试:

You can easily test this:

  1. 终止WhatsApp并开启飞行模式.
  2. 从 1 到 5 向您的设备发送 5 条消息.
  3. 关闭飞行模式并锁定您的设备.
  4. 在您的通知中心中,您只会看到一条信息(您发送的最后一条信息,即5").
  1. Terminate whatsApp and turn on Airplane mode.
  2. Send your device 5 messages from 1 to 5.
  3. Turn Airplane mode off and lock your device.
  4. You'll only see one msg (the last one you sent aka "5") in your notifications center.

这就是 WhatsApp 的工作原理:

当 WhatsApp 在后台时,会收到一条推送通知(用户发送的最后一条通知,在我们的示例中为5").该 msg 不会显示给用户.

While whatsApp is in the background, a single push notification is received (the last one the user sent, "5" in our example). That msg will not be shown to the user.

whatsApp 在方法 application:didReceiveRemoteNotification:fetchCompletionHandler: 中接收它,并检查他们的服务器是否在5"之前有任何用户没有收到的通知.如果是这种情况,他们将从他们的服务器中提取该数据,并使用本地通知将其呈现给用户,这基本上只是一种呈现数据的方式,与 APNS 完全无关.

whatsApp receives it in the method application:didReceiveRemoteNotification:fetchCompletionHandler: and checks against their servers if there are any notifications prior to "5" that the user didn't receive. If that's the case, they will pull that data from their servers and will present it to the user using local notifications which is basically just a way to present data and not related to APNS at all.

这篇关于Apple 多个推送通知在通知托盘中不可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆