Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to handle multiple push notifications received when iOS app is in FOREGROUND using iOS 6+ [duplicate]

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
like image 787
Bhavesh Dhaduk Avatar asked Nov 25 '22 01:11

Bhavesh Dhaduk


1 Answers

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.

like image 189
JiaYow Avatar answered Feb 17 '23 00:02

JiaYow