How do i handle (open alert for) all the UILocalNotification
on click of one notification since apple clears other notification from notification center on click of one notification...also if the user opens the app ignoring the notifications in notification center, how do i handle(open UIAlertView
for) them as well? i have seen this working perfectly in Calminder app
Asked
Active
Viewed 302 times
0

Mihriban Minaz
- 3,043
- 2
- 32
- 52

Hardik Amal
- 1,283
- 1
- 16
- 23
1 Answers
0
You can use [[UIApplication sharedApplication] scheduledLocalNotifications];
to get all the notifications that are previously scheduled. This method returns an NSArray
instance so you can run a for loop to handle these:
for (UILocalNotification *notification in [[UIApplication sharedApplication] scheduledLocalNotifications]) {
// Handling codes goes here.
}
If you wants to have some extra informations in the notification you can use the userInfo
property. It is a dictionary to store additional informations along the notification. You can set it like this:
notification.userInfo = // The dictionary goes here.
So now you can do this:
for (UILocalNotification *notification in [[UIApplication sharedApplication] scheduledLocalNotifications]) {
NSDictionary *userInfo = notification.userInfo;
// Handling codes goes here. Now you can use the user info dictionary to
// get what you stored into the userInfo dictionary when you are
// initializing the user info.
}
After this you can get all the informations and you can present it in an UIAlertView
.
To call these codes above at app's launch you can use two methods:
-application:didFinishLaunchingWithOptions:
or
-applicationDidBecomeActive:
Hope this helps.

Tom Shen
- 1,838
- 3
- 19
- 40
-
but if the repeat interval is not set,then that particular notification is removed from the scheduled array after firing...then how can i get the notification which is fired and had no repeatinterval set... – Hardik Amal Mar 04 '16 at 14:40
-
@HardikAmal Look at this question: http://stackoverflow.com/questions/22728179/how-to-get-already-fired-uilocalnotification – Tom Shen Mar 04 '16 at 14:43