Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I handle unread push notifications in iOS?
    text
    copied!<p>I have a iOS 5.1 application that registers to the APNS service to receive notifications. The register is successful and I receive the notifications correctly. The problem comes when I try to handle the notifications.</p> <p>Once the application is running, the method <code>didReceiveRemoteNotification</code> in the AppDelegate is called correctly and so the notification is handled as intended. This, however, only happens when the application is running on the foreground.</p> <p>However, when the application is running on the background or is simply stopped, that method is not called. I've read that you should add some lines to the method <code>didFinishLaunchingWithOptions</code> method to obtain the notification from the <code>userInfo</code> dictionary, and handle it. This works just fine, but ONLY when the application is opened by clicking on the notification at the Notification Center. This means that if you open the application by clicking on its badge, or simply by changing context if you were running it on the background, the app never realises that a notification came in. Additionally, if more than one notification was received, we can only handle one of them at once by clicking on the Notification Center, which is a pain :-)</p> <p>Is there any way to read the pending notifications in the Notification Center? I know there is a way to flush them using the method <code>cancelAllLocalNotifications</code> but I haven't found a way to just read them. And I really need to handle all of them. I thought of implementing a communication protocol with the third-party notification server to retrieve the information again when the application comes to the foreground, but since the information is already in the operating system I would find it strange if it's impossible to access it somehow.</p> <p>So, does anybody know a way to do it? Thanks in advance.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload