I want to get all the notifications
related to my app which is stored in the notification center
of the iPhone. How can I get this
?

- 3,885
- 10
- 39
- 65
3 Answers
You can use [[UIApplication sharedApplication] scheduledLocalNotifications]
to get the complete list of scheduled notifications. Hope it'll help. Enjoy Coding.

- 1,681
- 4
- 28
- 61
-
but i'am not getting the remote notifications which is already in the notification center – Dev Dec 28 '12 at 06:16
-
No, this is not possible, because push notification handled by Apple server. So as far as i know this is not possible. – josh Dec 28 '12 at 06:21
-
josh has right: the push is comming from a callback to your app, and you should register to receive the callback. You can save the notif and read back later, but push aren't stored in notif center on that way – Dec 28 '12 at 06:24
For Local Notification, you can get all the notifications related to that app using,
[[UIApplication sharedApplication] scheduledLocalNotifications]
But for Push notification, i dont think its possible, but the another way to achieve this is, if the user views/select a push notification, then you should store it in your local.

- 15,055
- 6
- 50
- 72
-
@Dev Then there's nothing you can do beyond asking the server (NOT Apple's APN server) that sent the push notification for any/all notifications that have been sent. – Kitsune Dec 28 '12 at 06:27
-
upvoted both answer, imho this should be accpeted, because it says what to do with push – Dec 28 '12 at 06:29
-
[[UIApplication sharedApplication] cancelAllLocalNotifications]; deletes all the notifications from the notification center both local and remote. Then why cant we get all the notifications? – Dev Dec 28 '12 at 06:33
-
@Dev If the user closes, you cant do anything with that notification. Even cant handle the cancel event. – KingofBliss Dec 28 '12 at 06:36
-
When my app is not in the foreground state, i got two remote notifications and i press close button. And in the notification center i can see that two notifications. – Dev Dec 28 '12 at 06:38
-
And in my app, in the delegate method applicationDidEnterBackground i wrote the code [[UIApplication sharedApplication] cancelAllLocalNotifications]; So after entering to foreground if my app is going to background all the notifications which is in the notification center getting erased. – Dev Dec 28 '12 at 06:40
-
[[UIApplication sharedApplication] cancelAllLocalNotifications]; is to cancel local notifications, not to clear the notifications in notification center. Your app might get crashed due to some other code. Please recheck – KingofBliss Dec 28 '12 at 07:20
it was described already the Local and Push notifications in previous 2 answers.
What else is stored into notification center
can be a good example here:
It is intended to be used as communication between UI elements, screens, background. But can be used for other "almost legal" stuff, which will not bypass the Apple code review: private API, hacking and such if is started to use in "not as intended by Apple" :)
It is in the notification center and it is a notification too.
I am sure not about this are you asking, because of:
"related to my app"
this is related to a component of your app.

- 1
- 1