I have an iOS 5.1 application that registers with APNS to receive notifications. Register is successful, and I receive notifications correctly. The problem occurs when I try to process notifications.
Once the application is launched, the method didReceiveRemoteNotificationin AppDelegate is called correctly, and therefore the notification is processed as intended. This, however, only happens when the application is running in the foreground.
However, when the application is running in the background or just stopped, this method is not called. I read that you have to add some lines to the method didFinishLaunchingWithOptionsto receive notification from the dictionary userInfoand process it. This works fine, but ONLY when the application opens by clicking a notification in the Notification Center. This means that if you open the application by clicking on its icon or simply changing the context, if you launch it in the background, the application never understands that a notification is coming. In addition, if more than one notification is received, we can only process one of them at a time by clicking on the Notification Center, which is a pain :-)
Is there a way to read pending notifications in the Notification Center? I know that there is a way to reset them using the method cancelAllLocalNotifications, but I have not found a way to simply read them. And I really need to handle all of them. I was thinking about implementing a protocol for communicating with a third-party notification server in order to get information again when the application comes to the fore, but since the information is already in the operating system, it would be strange for me if it were not possible to access it in any way .
So, does anyone know a way to do this? Thanks in advance.
source
share