Schedule number of Local Notifications

Minkle Garg picture Minkle Garg · Oct 11, 2011 · Viewed 10.4k times · Source

I am making an iPhone application in which I have implemented the concept of local notification to alert the user for taking medicine.

But in iOS we can't schedule more than 64 notifications at a time. But I have a number of date-time entries in the database. How could I schedule more than 64 notifications?

Answer

EmptyStack picture EmptyStack · Oct 11, 2011

As you are already aware, you can schedule maximum of 64 notifications per app. If you add more than that, the system will keep the soonest firing 64 notifications and will discard the other.

One way to make sure all notifications get scheduled is to schedule the first 64 notifications first, and then on regular time intervals (may be on every launch of the app or each time a notification fires) check for the number of notifications scheduled and if there are less than 64 notifications, lets say n notifications, then schedule the next (64 - n) notifications.

int n = [[[UIApplication sharedApplication] scheduledLocalNotifications] count];
int x = 64 - n;
// Schedule the next 'x' notifications