1 台设备上的多个推送通知 - iPhone [英] Multiple push notifications on 1 device - iPhone
问题描述
如何在一台设备上处理多个推送通知,例如:
用户收到一条通知,说您有 1 条来自我的应用的新消息.在他检查该消息之前,另一条消息进来了,所以现在他有 2 条消息.好吧,我不想在通知栏中堆叠 2 条消息,我想要 1 条通知,说有 2 条消息在等待.我该如何实施?
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?
而且如果在设备上收到 5 个新通知并且用户点击最后一个通知,那么我们如何获得上一个通知 userInfo
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
推荐答案
关于您的第一个问题,您将无法执行此操作.通知是单独的事件,NotificationCenter 不会(也不能)合并它们.
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.
推送通知并不意味着传递(很多)信息,因此,您不能依赖于读取 userInfo 对象.例如,如果用户只是关闭通知警报并删除它而没有阅读它,您会怎么做?
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.
这篇关于1 台设备上的多个推送通知 - iPhone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!