iOS 上的重复推送通知 [英] Duplicate push notifications on iOS

查看:72
本文介绍了iOS 上的重复推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能与重复的Apple APNS推送通知?相同,但是既然那个人没有得到答复,而且我有更多信息,我会尝试再次询问.

This question is probably the same as Duplicate Apple APNS push notifications?, but since that one didn't get an answer, and I have some more information, I'll try to ask it again.

重现问题的步骤:

  • 将通知中心设置为将通知显示为警报,这会使问题更加明显.
  • 确保应用没有在前台运行.
  • 快速连续发送 3 条相同的推送通知.
  • 等待消息到达手机,您现在必须关闭提醒 3 次.
  • 现在再发送 1 个通知,这与之前的不同.
  • 您现在会收到最后一条通知,但还会再次显示之前的一条通知.这就是问题所在.
  • 如果您继续发送单个通知,前 3 个通知中的一个将在不应该弹出时继续弹出.

这是一个按照这些步骤操作的视频,它清楚地显示了问题:

Here is a video that follow these steps, which clearly shows the problem:

http://youtu.be/TSqt8S4FY6w

我们就像 Remy Gale 在上面链接的问题中所做的那样,确保我们的通知以正确的方式发送,并且每个通知只发送一次.我们还使用沙箱 apns 和生产 apns 对此进行了测试,两者的行为完全相同.

We have just as Remy Gale did in the linked question above made sure that our notifications are sent in the correct way, and only once per notification. We have also tested this with both the sandbox-apns and the production-apns, both behave exactly the same.

如果 app-badge 设置为 0,问题就会消失,这反过来会从通知中心删除所有通知.手动删除通知无济于事.

The problem disappears if the app-badge is set to 0, which in turn removes all notifications from notification center. Removing the notifications manually doesn't help.

UIApplication *app = [UIApplication sharedApplication];
app.applicationIconBadgeNumber = 0;

但这不是解决方案.

如果所有通知都包含唯一文本,则不会出现此问题.将 GUID 添加到警报文本将使问题消失.但是,将其作为自定义属性或本地化参数添加到 apns-payload 中无济于事,因此这也不是解决方案.

The problem doesn't appear if all notifications contain unique text. Adding a GUID to the alert-text will make the problem disappear. Adding it to the apns-payload as a custom property or as a localized argument will however not help, so this is also not a solution.

这种情况在具有实时应用的生产环境中可能很少发生,但它可能会发生,而且一旦发生,对用户来说真的很烦人!

This will probably rarely happen in a production environment with a live app, but it can happen, and when it does, it is really annoying for the users!

有谁知道为什么会这样?有人有可行的解决方案吗?

Does anyone know why this happen? Does anyone have a viable solution?

推荐答案

这个 Google Group for Gmail 有一个用户的条目,该用户对该错误进行了一些研究,并提供了可能的解决方法.根据条目,该错误在 iOS 5 中不存在,但在 iOS 6 中引入.

This Google Group for Gmail has an entry from a user who has researched the bug a bit and includes a possible workaround. According to the entry the bug is not present in iOS 5 but was introduced with iOS 6.

解决方法是简单地附加一个随机数的零宽度非连接器 添加到标题以确保唯一性.

The workaround is simply appending a random number of Zero-width non-joiner to the title in order to assure uniqueness.

这篇关于iOS 上的重复推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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