Handle remote APNS notifications while running

I applied all the recommended methods in AppDelegate to get a working remote notification service.

I can take them at work, at startup and shutdown.

But there is a problem, since I can not work with many received notifications in the background. I can only work with the latest notification.

What is recommended for this? How can I get all the notifications received in the background? Is this allowed only by manually calling my service provider (apns data sender)?

+7
source share
3 answers

With all the projects that I worked on, there was no way to locally store this information if the push notification was rejected. In all these cases, we used a small file on the server to which the application would connect and pull when it was activated again. The application also had a place where the user could see all his notifications, which, again, were stored on the server for quick retrieval.

When I understand that push notifications are configured, if the notification is rejected, the system discards it. He will do everything he needs to do (for example, update the icon number and play the correct sound), but any additional information related to this notification will be lost.

+6
source

Not sure if this will help, but if you just want to find out how many notifications you missed when you were in the background. You can create a variable containing the notification number and save it in the application each time you process the notification. When you exit the background and receive a new notification, you can subtract the new number with the saved number to find out the number of missed notifications. I do not think that there is a way in which iOS can provide you with complete data related to the entire notification device received when the application was in the background.

+3
source

The best solution is to save the list of sent notifications with all the relevant data on your server so that the application can access this data at startup. Sending multiple notifications with data that is not stored on the server can be risky, because the application receives a notification only when the user opens the application from this notification , so if they click on one notification, each application will receive only one.

If you have everything in the list on your server, the application can simply go and pull this list down and process it, making sure that the data is not lost.

+3
source

All Articles