Fire local notification every day on different times

I'm developing a project that notifies the user every day on a different time from a pre-defined database, five times a day to be precise.

My problem is how schedule all these times, 5times*365days = 1825 fire dates !! is it possible to schedule them all?

any ideas would be very much appreciated


According to Apple documentation:

An application can have only a limited number of scheduled notifications; the system keeps the soonest firing 64 notifications (with automatically rescheduled notifications counting as a single notification) and discards the rest

I solved that problem by setting a "queue" of notifications. For example, in my app I have three different types of notifications, let's just say type A, B and C.

I schedule the A, B and C notifications for the next month, everytime the user opens the app, I checked how many notifications left. If, for example, the are no more A notifications, the app schedules more A notifications and so on.

How I achieve this?

Everytime I schedule a notification, I use the userInfo property. I set a dictionary with a key called type and a value.

In my app delegate I check all the pending notifications and count how many left for each type. The code looks like this:

NSArray *scheduledNotifications = [UIApplication scheduledLocalNotifications];

NSUInteger AType, BType, CType;

for (UILocalNotification *notif in scheduledNotifications) {
        //Classify notifications by type
        NSUInteger notifType = [[notif.userInfo objectForKey:@"type"]integerValue];
        if (notifType == 0) {
           AType++;
        }else if(notifType == 1){
            BType++;
        }else{
            CType++;
        }

}

If the count of any type is zero the app schedules more notifications.

Finally, if the notifications are show for example, everyday at the same hour you can use the repeatInterval property BUT you can't create your own repeating intervals, you can only use the repeating intervals defined in NSCalendarUnit.

Hope it helps.


You could try Eventkit framework using that you could add reminders,events,alarms.

1)It has no number of notification limitation like UILocalNotification.

2)With event kit you could add both time based as well location based events.

3)You don't need to worry about privacy too.

Although both UILocalNotification and EventKit is powerful in its own right..

Note that:ios 6 or above for EventKit framework

It's upto you to choose which one depending upon your needs.

The below links will give you good headstart

Resource 1

Resource 2.

The image below will give you a nice peek of what evenkit is.

EventKit_image

Use eventkit if it suits your need.