1 台设备上的多个推送通知 - iPhone
如何在一台设备上处理多条推送通知,例如:
用户收到一条通知,称您有来自我的应用的 1 条新消息。在他检查该消息之前,另一条消息进来,所以现在他有 2 条消息。好吧,我不希望 2 条消息堆叠在通知栏中,我想要 1 条通知,表示有 2 条消息正在等待。我该如何实施?
另外,如果设备上收到 5 个新通知并且用户点击了最后一个通知,那么我们如何获取上一个通知 userInfo
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
How to handle multiple push notifications on One device e.g:
A user receives a notification saying you have 1 new message from my app. Before he checks that message another message comes in so now he has 2. Well I don't want 2 messages stacked in the notification bar, I want 1 notification saying there are 2 messages waiting. How do I implement this?
And also if on device got 5 new notification and user taps last notification then how we got the previous notification userInfo
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于你的第一个问题,你将无法做到这一点。通知是单独的事件,NotificationCenter 不会(也不能)合并它们。
推送通知并不意味着传递(太多)信息,因此,您不能依赖于读取 userInfo 对象。例如,如果用户没有阅读通知警报就直接关闭并删除它,您会怎么做?
您应该做的只是使用推送通知来告诉您的应用程序“发生了一些事情”。然后应用程序应该从服务器获取信息。即,如果用户点击最后一个通知,应用程序仍会下载链接到所有五个通知的所有信息。
Regarding your first question, you won't be able to do this. Notifications are seperate events, and NotificationCenter won't (and can't) merge them.
Push notifications aren't meant to deliver (much) information, hence, you cannot rely on reading the userInfo objects. For example, what would you do if the user just closes the notification alert and deletes it without reading it?
What you should do is only use Push notifications to tell your app that "something has happened". The app should then fetch the information from the server. I.e, if the user taps on the last notification, the app will still download all the information linked to all five notifications.